-
Notifications
You must be signed in to change notification settings - Fork 93
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
implement haproxy socket type from configuration #125
base: master
Are you sure you want to change the base?
Conversation
fcbfdc8
to
3c5d979
Compare
@@ -93,6 +99,8 @@ create_luasocket = do | |||
ngx.socket.tcp! | |||
when "luasocket" | |||
create_luasocket! | |||
when "haproxy" | |||
create_luasocket("haproxy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@leafo using your create_luasocket
interface now instead, just using the raw core.tcp
wasn't playing well with the expected socket API.
we are also using haproxy in lua and would love to be able to use this api! |
plus one! |
Would be helpful for us as well. |
Just adding comment in case it's helpful to anyone: if it's API compatible with LuaSocket then you can run Be warned, I have no idea how this will play with ssl. (This change in this patch too is unknown) |
3c5d979
to
bb3dfae
Compare
I tried using function connect_db(pg_settings)
-- Returns a pgmoon postgres object or nil on failure.
package.loaded.socket = core
local pg = pgmoon.new(pg_settings)
-- Set the timeout value (in milliseconds) for all socket operations
-- (connect, write, receive)
pg:settimeout(5000)
pg.convert_null = true -- https://github.com/leafo/pgmoon#converting-nulls
local success, err = pg:connect() However this does not seem to work. |
When the Lua HAProxy `core` object is detected, the socket class will automatically use its (non-blocking) socket type. The pattern is similar to existing auto-detection of whether pgmoon is running inside an NGINX context or not and choosing that socket type if so. http://www.arpalert.org/src/haproxy-lua-api/1.7/index.html#core.get_info
bb3dfae
to
bb54268
Compare
Surprising it didn't work since the HAProxy Lua API docs specify the same constraint:
https://www.arpalert.org/src/haproxy-lua-api/2.6/index.html#Socket |
Resolves #114.
When the Lua HAProxy
core
object is detected, the socket class willautomatically use its (non-blocking) socket type. The pattern is similar
to existing auto-detection of whether pgmoon is running inside an NGINX
context or not and choosing that socket type if so.
http://www.arpalert.org/src/haproxy-lua-api/1.7/index.html#core.get_info