Module: PGMQ::Transaction
- Included in:
- Client
- Defined in:
- lib/pgmq/transaction.rb
Overview
Low-level transaction support for PGMQ operations
Provides atomic execution of PGMQ operations within PostgreSQL transactions. Transactions are a database primitive - this is a thin wrapper around PostgreSQL’s native transaction support.
This is analogous to rdkafka-ruby providing Kafka transaction support - it’s a protocol/database feature, not a framework abstraction.
Defined Under Namespace
Classes: TransactionalClient
Instance Method Summary collapse
-
#transaction {|PGMQ::Client| ... } ⇒ Object
Executes PGMQ operations atomically within a database transaction.
Instance Method Details
#transaction {|PGMQ::Client| ... } ⇒ Object
Executes PGMQ operations atomically within a database transaction
Obtains a connection from the pool, starts a transaction, and yields a client that uses that transaction for all operations.
39 40 41 42 43 44 45 46 47 |
# File 'lib/pgmq/transaction.rb', line 39 def transaction @connection.with_connection do |conn| conn.transaction do yield TransactionalClient.new(self, conn) end end rescue PG::Error, StandardError => e raise PGMQ::Errors::ConnectionError, "Transaction failed: #{e.}" end |