Module: Pgque

Defined in:
lib/pgque/event.rb,
lib/pgque.rb,
lib/pgque/client.rb,
lib/pgque/errors.rb,
lib/pgque/message.rb,
lib/pgque/version.rb,
lib/pgque/consumer.rb

Overview

Copyright 2026 Nikolay Samokhvalov. Apache-2.0 license.

Defined Under Namespace

Classes: BatchNotFound, Client, ConnectionError, Consumer, ConsumerNotFound, Error, Event, Message, QueueNotFound

Constant Summary collapse

VERSION =
"0.3.0.rc.1"

Class Method Summary collapse

Class Method Details

.connect(dsn) ⇒ Object

Open a connection and return a Pgque::Client.

Ruby’s pg gem runs each statement in its own implicit transaction by default – the equivalent of psycopg’s autocommit=True. To group statements into one transaction, use conn.transaction { … } on the underlying PG::Connection (client.conn). There is no autocommit flag because Ruby pg has no per-connection autocommit attribute to toggle; transaction control is per-call via the transaction block.



25
26
27
28
29
30
31
32
33
34
# File 'lib/pgque.rb', line 25

def self.connect(dsn)
  client = Client.connect(dsn)
  return client unless block_given?

  begin
    yield client
  ensure
    client.close
  end
end