Skip to content
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

connect blocks #35

Closed
jsaak opened this issue Apr 14, 2016 · 4 comments
Closed

connect blocks #35

jsaak opened this issue Apr 14, 2016 · 4 comments

Comments

@jsaak
Copy link

jsaak commented Apr 14, 2016

I did not even install your driver, but looking at the code, it must be blocking.
The node guys went for a background thread solution, since libpg async methods block as well:
https://github.com/brianc/node-libpq
https://www.npmjs.com/package/pg-libpq

To be honest i came to your repo to find out how crystal handles async IO. Maybe there is no support yet, I do not know.

@asterite
Copy link
Contributor

The ideal solution is to implement the postgres protocol using Crystal's IO classes (like Socket) which are non-blocking by default. It's a lot of work, but it's the best solution (many other languages implement it this way too, for example Go)

@jsaak
Copy link
Author

jsaak commented Apr 14, 2016

Is there any workaround until that day comes?

@will
Copy link
Owner

will commented Apr 17, 2016

Currently, while postgres is working on the query, that is async. It's only while sending and receiving data that is sync due to libpq. There is no workaround for that.

Going native does have both that upside, and would fix the linking problems (#13 and crystal-lang/crystal#1269). However we'd no longer get new authentication schemes for free (it's looking like SCRAM will make it in soon), and small nice things like the default socket location being known will be lost or have to be reimplemented. At least the protocol isn't too complicated, especially compared to others.

@will
Copy link
Owner

will commented May 5, 2016

The driver is now native

@will will closed this as completed May 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants