Sha256: 09bae671a0917e2f167ca596ac43791090529936d932fd786943198686de07e6
Contents?: true
Size: 970 Bytes
Versions: 14
Compression:
Stored size: 970 Bytes
Contents
# frozen_string_literal: true module PgEventstore # @!visibility private class TransactionQueries attr_reader :connection private :connection # @param connection [PgEventstore::Connection] def initialize(connection) @connection = connection end # @return [void] def transaction connection.with do |conn| # We are inside a transaction already - no need to start another one if [PG::PQTRANS_ACTIVE, PG::PQTRANS_INTRANS].include?(conn.transaction_status) next yield end pg_transaction(conn) do yield end end end private # @param pg_connection [PG::Connection] # @return [void] def pg_transaction(pg_connection) pg_connection.transaction do pg_connection.exec("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE") yield end rescue PG::TRSerializationFailure, PG::TRDeadlockDetected retry end end end
Version data entries
14 entries across 14 versions & 1 rubygems