nikita-volkov / hasql-pool

A pool of connections for Hasql
http://hackage.haskell.org/package/hasql-pool
MIT License
17 stars 15 forks source link

Add a hook into the connection initialization phase #44

Closed nikita-volkov closed 4 months ago

nikita-volkov commented 5 months ago

Any opinions or wishes for changes on this?

@steve-chavez @robx @domenkozar

steve-chavez commented 5 months ago

@nikita-volkov What's the motivation for this PR?

nikita-volkov commented 5 months ago

To provide a way for the user to issue some commands on every established connection prior to it becoming available for execution of statements thru the pool. E.g., to configure connections by issuing a bunch of SET commands.

steve-chavez commented 5 months ago

Ah nice, it enables session variables then. If the connection dies, will the session variable survive?

nikita-volkov commented 5 months ago

I'm not sure what you imply by connection dying and variable surviving.

The same session will be reexecuted each time a connection gets established by the pool for whatever reasons. That means that it'll be safe to assume that every connection used by the pool will be running having that session executed.