-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Update (Mon Oct 29 2019):
A conversation with @aaronjensen triggered the realization that this would be easier (and likely a better design) if an implementation of MessageStore::Postgres::Session were build that is constructed with an ActiveRecord connection, and that respects the Session's interface and semantics. If that's feasible, then that session can be injected into any Eventide primitive (eg: a writer) that accepts a session.
Enables writing to ActiveRecord and message store in an atomic transaction.
The MessageStore::Postgres::Session would have to be redesigned so that it could be built around an existing connection, rather than constructing its own. The connection and transaction lifecycle could likely also not be managed by the session.
This type of Session object may need to be an entirely separate implementation. Inevitably, it would necessitate the initiation of a new and separate library that compartmentalizes all of the ActiveRecord concerns and isolates the rest of the toolkit from any of the invidious effects of integrating with ActiveRecord.
Research work needed:
- The connection and its transaction authority extended to the Eventide session must absolutely be the same one that is in use within the Rails applicative code that is actuating the Eventide session. If it's not, then the goal of atomicity will not be achieved.
- Gain access to a raw PG connection (from the PG gem) so that it can be assigned to an Eventide Session. It must be the connection object from the PG gem, as this is the interface that the Eventide Session interacts with. It must be confirmed that the PG adapter for ActiveRecord uses the PG gem.
- Ensure that ActiveRecord can remain in control of the connection lifecycle, and that opportunities to leak the connection are neutralized
Supporting Material:
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html#method-i-active_connection-3F
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html#method-i-connection
- https://github.com/rails/rails/blob/09a2979f75c51afb797dd60261a8930f84144af8/activerecord/lib/active_record/transactions.rb#L211