Open Lilit0x opened 6 days ago
Hello @Lilit0x , may I know if your startup handler is a stateful one or stateless, in other words, do you need to create new instance of the handlers for each incoming connection?
I have to say my current naming of the trait, PgWireHandlerFactory
might be confusing because the methods in trait may not allow you to customize the handler based on incoming connection. So in most case, this factory is only a cache for different set of handlers. If you handlers are stateful, you will need to build these handlers before calling process_socket
and cache it in a struct that implements PgWireHandlerFactory
. And if it's stateless, you can simply cache them in a global struct or just create it when those handler methods called.
I may rename this PgWireHandlerFactory
to PgWireHandlers
in next patch release hoping make it a little bit clear.
I'm constructing a Postgres proxy that simulates an actual Postgres server. For this, I've created a custom
StartupHandler
andAuthSource
usingpgwire v0.22.0
. The implementation is as follows:When upgrading to
pgwire v0.24.2
, the challenge arises in delivering theconfig_tx
to theStartupHandler
through the newPgWireHandlerFactory
.Do you by chance have a suggestion on how to do this or support passing custom parameters to the
PgWireHandlerFactory
trait? Please let me know if you need any further details. Thanks.