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

expose withConnection #9

Closed docteurklein closed 2 years ago

docteurklein commented 4 years ago

Hello :)

I hope this makes sense, but I'm desperately trying to use hasql-queue and hasql-notification with a connection pool, like that: https://github.com/docteurklein/schloss/blob/7f03f734bccfa4632b422039113101db134a8c72/src/Main.hs#L140-L143

Is that something I could do otherwise? Thanks, Florian.

nikita-volkov commented 4 years ago

Seems like there wouldn't be a need for that if there was a withDequeue operation running in Session. Please consider reporting that to the maintainers of the queue package.

docteurklein commented 4 years ago

@jfischoff is that something that could be done in both hasql-queue and hasql-notifications?

jfischoff commented 4 years ago

withDequeue could have a Session interface but it might give people the impression that you could use it in a transaction ... but you can't because of the use of notifications.

Why not just use Data.Pool directly? It is nearly as easy to use as this library.

docteurklein commented 4 years ago

yes, maybe using Data.Pool is the solution for me. I tried already, but I kinda repeated the boilerplate that hasql-pool solved (I guess :)).

Concerning postgres notifications, they are supported in transactions; they are all released after commit (https://www.postgresql.org/docs/current/sql-notify.html#id-1.9.3.157.5) if that's what you meant?

Thanks for the answers :)

jfischoff commented 4 years ago

Ah right, I misremembered. The problem with withDequeue in a transaction is it would keep the transaction open for a long time which is not a great practice.

nikita-volkov commented 2 years ago

This should be addressed by Session providing access to the connection via MonadReader now.