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

Support for HAProxy Lua non-blocking core.Socket #114

Open
mecampbellsoup opened this issue Dec 25, 2021 · 3 comments · May be fixed by #125
Open

Support for HAProxy Lua non-blocking core.Socket #114

mecampbellsoup opened this issue Dec 25, 2021 · 3 comments · May be fixed by #125

Comments

@mecampbellsoup
Copy link
Contributor

Description

We are using pgmoon inside of HAProxy Lua to connect to our Postgres DB server, make queries, establish LISTEN pgnotify clients, etc.

However the standard Lua Socket class is blocking as you can see from the source code.

TODO: describe the blocking nature of luasocket more clearly above

From an HAProxy blog post:

The Socket class is a replacement for the standard Lua Socket class and is compatible with HAProxy’s non-blocking nature. When you want to use socket functions in your actions, you must use this class.

As such we forked pgmoon and simply replaced luasocket with HAProxy's non-blocking Lua Socket class.

We'd like to discuss how to get his merged upstream so that others can benefit and we can get back onto using a non-forked pgmoon implementation.

I'll open a PR and link it to this issue with our naive implementation but we'd like to hear thoughts/suggestions on getting this feature merged.

Merry X-mas @leafo! 😄

cc @kriscode1

@leafo
Copy link
Owner

leafo commented Dec 25, 2021

The socket initialization is a bit confusing at the moment, but I think the best approach would be to provide a new sock_type option to the constructor that instructs the HAProxy module to be used.

@mecampbellsoup
Copy link
Contributor Author

The socket initialization is a bit confusing at the moment, but I think the best approach would be to provide a new sock_type option to the constructor that instructs the HAProxy module to be used.

You mean this constructor (of the TCP socket) right?

@mecampbellsoup
Copy link
Contributor Author

mecampbellsoup commented Dec 26, 2021

You mean this constructor (of the TCP socket) right?

There's already a socket_type argument passed to the constructor AFAICT.

https://github.com/mecampbellsoup/pgmoon/blob/da82db087b53450788204321d59afa44e3539a7a/pgmoon/socket.lua#L86-L93

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

Successfully merging a pull request may close this issue.

2 participants