how to set properties of connection pool?
Closed this issue · 9 comments
such as pool's size, min and max value, keepalive time, etc.
You can pass the same parameters you pass to the ngx keepalive method to the pg object's keepalive method
https://github.com/leafo/pgmoon#success-err--postgreskeepalive
But I didn't find parameters in the source code of pgmoon/init.moon and pgmoon/socket.lua.
By the way, would you please upload pgmoon to http://opm.openresty.org/ ? So I can use opm command to update pgmoon.
@gzliudan the ...
is used to pas parameters through to openresty, so their names aren't explicitly listed in this project's source code
I updated the package on opm
thanks a lot. I updated pgmoon through opm command.
Can you give an example how to set parameters of connection pool?
-- when you want to return the connection to the pool:
pg:keepalive(timeout, pool_size)
-- if you need to configure the pool name:
pgmoon.new({
pool = "custom pool name",
-- ...
})
Generally you don't need to configure the pool name since it will choose a reasonable default based on connection settings.
Thank you very much.
Does the unit of timeout is second? What happenes if pool_size is different value when call pg:keepalive with last time.
Check out the docs https://github.com/openresty/lua-nginx-module#tcpsocksetkeepalive
Thank you again. Maybe it's better update ReadMe.
52 closed, continue here.
There are similar issues: 47, 64
How to limit connections in openresty? The answer is here
Basically, we cannot strictly limit connections, in practice, lua_socket_pool_size
or #tcpsocksetkeepalive
is both overflow-able, that's why cosocket has huge concurrency.
openresty group has more details, for example this