Hi,
When implementing OAuth support in the PostgreSQL driver for Ruby[1] the
main pain point I ran into was that the PQauthDataHook is global which
does not work well at all given how Ruby supports multiple sub-instances
of the Ruby runtime (so called Ractors) plus that if you would load e.g.
Python and Ruby into the same process and both would use libpq they
would have to fight over the global hook.
So attached is a proof of concept patch which implements a
per-connection hook. It is just a rough patch to start a discussion. If
people like it I can clean it up and add tests and documentation.
Notes
1. See these two PRs: one which uses a per-runtime map and one which
uses a per-PGConn hash map. I am not a fan of either.
- https://github.com/ged/ruby-pg/pull/693
- https://github.com/ged/ruby-pg/pull/700
--
Andreas Karlsson
Percona