Class: PgEventstore::Connection
- Inherits:
-
Object
- Object
- PgEventstore::Connection
- Defined in:
- lib/pg_eventstore/connection.rb
Instance Attribute Summary collapse
- #pool_size ⇒ Integer writeonly
- #pool_timeout ⇒ Integer writeonly
- #uri ⇒ String writeonly
Instance Method Summary collapse
-
#initialize(uri:, pool_size: 5, pool_timeout: 5) ⇒ Connection
constructor
A new instance of Connection.
- #shutdown ⇒ void
-
#with {|connection| ... } ⇒ Object
A shorthand from ConnectionPool#with.
Constructor Details
#initialize(uri:, pool_size: 5, pool_timeout: 5) ⇒ Connection
Returns a new instance of Connection.
26 27 28 29 30 31 |
# File 'lib/pg_eventstore/connection.rb', line 26 def initialize(uri:, pool_size: 5, pool_timeout: 5) @uri = uri @pool_size = pool_size @pool_timeout = pool_timeout init_pool end |
Instance Attribute Details
#pool_size=(value) ⇒ Integer
16 17 18 |
# File 'lib/pg_eventstore/connection.rb', line 16 def pool_size @pool_size end |
#pool_timeout=(value) ⇒ Integer
19 20 21 |
# File 'lib/pg_eventstore/connection.rb', line 19 def pool_timeout @pool_timeout end |
#uri=(value) ⇒ String
13 14 15 |
# File 'lib/pg_eventstore/connection.rb', line 13 def uri @uri end |
Instance Method Details
#shutdown ⇒ void
This method returns an undefined value.
52 53 54 |
# File 'lib/pg_eventstore/connection.rb', line 52 def shutdown @pool.shutdown(&:close) end |
#with {|connection| ... } ⇒ Object
A shorthand from ConnectionPool#with.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pg_eventstore/connection.rb', line 36 def with(&) should_retry = true @pool.with do |conn| yield conn rescue PG::ConnectionBad, PG::UnableToSend # Recover a connection after fork or when we lost a connection to PostgreSQL. We retry only once and without any # delay. conn.sync_reset raise unless should_retry should_retry = false retry end end |