-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event loop integration #28
Comments
What makes you think the first approach is not preferred? It seems simpler (not burdening client code with initiating the actual connection), and quite harmless. |
I think it'll be trickier, because getting the file descriptor for a connection requires implementation specific code depending on the type of socket you're using, etc. Furthermore, the reconnection case can be tricky to handle too. That's why the second approach seems easier to me. |
Since usocket doesn't provide a way to get a file descriptor from a socket (or a socket from a file descriptor), it seems there's going to be some unportable code anyway. At least, I don't see a way around it. My scheme would require the client code to deliver whatever CL-Postgres uses as a socket on that implementation, and to handle reconnects you'd just make sure to fetch the current file descriptor from the connection right before you wait on it. If it's broken, then it'll immediately be returned, and control will be passed to CL-Postgres, which will handle the reconnect, do something, and then return to your loop so that you can wait on it again. |
It seems possible to retrieve a fd from a socket, see orthecreedence/cl-async#41 (comment) |
Surely it's possible, but not portably (the code there only has cases for four implementations). |
Ah, sure, sorry your sentence wasn't clear in this regard. :) That's why I though my second proposal was better, it's way more portable in the sense portability doesn't depends on cl-postgres, but on the user. But IIUC, this is also what you end up proposing. I've already managed to do this successfully with |
Your second proposal has the same problem though -- if you give CL-Postgres a raw file descriptor, it'll have to wrap it itself (using lots of |
My second proposal doesn't talk about a raw file descriptor, but a socket. Maybe even a stream might work and would be better (higher level)? |
It looks like the |
JD, is this still an issue for you? |
@sabracrolleton It's not an active issue anymore but the problem might still exist AFAIK. |
I'd like to use postmodern, and therefore a PG connection, into an event loop such as cl-async. To do that, I see 2 ways:
database-connection
class so the file descriptor can be retrieved and passed tocl-async
(not the preferred way I'd say)cl-postgres
so it uses it directly (probabaly the best way). One could also provide a function rather than a socket, to recreate the socket in case of a disconnection for example.The text was updated successfully, but these errors were encountered: