Class: PgEventstore::Config

Inherits:
Object
  • Object
show all
Includes:
Extensions::OptionsExtension
Defined in:
lib/pg_eventstore/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Extensions::OptionsExtension

included, #options_hash, #readonly!, #readonly?

Constructor Details

#initialize(name:, **options) ⇒ Config

Returns a new instance of Config.

Parameters:

  • name (Symbol)

    config’s name. Its value matches the appropriate key in PgEventstore.config hash



60
61
62
63
# File 'lib/pg_eventstore/config.rb', line 60

def initialize(name:, **options)
  super
  @name = name
end

Instance Attribute Details

#connection_pool_sizeInteger

Returns Max number of connections per ruby process.

Returns:

  • (Integer)

    Max number of connections per ruby process



28
# File 'lib/pg_eventstore/config.rb', line 28

option(:connection_pool_size) { 5 }

#connection_pool_timeoutInteger

Returns Time in seconds to wait for the connection in pool to be released.

Returns:

  • (Integer)

    Time in seconds to wait for the connection in pool to be released



31
# File 'lib/pg_eventstore/config.rb', line 31

option(:connection_pool_timeout) { 5 }

#event_class_resolver#call

Returns A callable object that must accept a string and return a class. It is used when resolving event’s class during event’s deserialization process.

Returns:

  • (#call)

    A callable object that must accept a string and return a class. It is used when resolving event’s class during event’s deserialization process



25
# File 'lib/pg_eventstore/config.rb', line 25

option(:event_class_resolver) { EventClassResolver.new }

#failed_subscription_notifier#call?

Returns provide callable object that accepts Subscription instance and error. It is useful when you want to be get notified when your Subscription fails and no longer can be restarted.

Returns:

  • (#call, nil)

    provide callable object that accepts Subscription instance and error. It is useful when you want to be get notified when your Subscription fails and no longer can be restarted



54
# File 'lib/pg_eventstore/config.rb', line 54

option(:failed_subscription_notifier)

#max_countInteger

Returns Number of events to return in one response when reading from a stream.

Returns:

  • (Integer)

    Number of events to return in one response when reading from a stream



17
# File 'lib/pg_eventstore/config.rb', line 17

option(:max_count) { 1000 }

#middlewaresHash{Symbol => <#serialize, #deserialize>}

Returns A set of identified(by key) objects that respond to #serialize and #deserialize.

Returns:

  • (Hash{Symbol => <#serialize, #deserialize>})

    A set of identified(by key) objects that respond to #serialize and #deserialize



21
# File 'lib/pg_eventstore/config.rb', line 21

option(:middlewares) { {} }

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/pg_eventstore/config.rb', line 7

def name
  @name
end

#pg_uriString

Returns:



12
13
14
# File 'lib/pg_eventstore/config.rb', line 12

option(:pg_uri) do
  ENV.fetch('PG_EVENTSTORE_URI') { 'postgresql://postgres:postgres@localhost:5432/eventstore' }
end

#subscription_graceful_shutdown_timeoutInteger

Returns the number of seconds to wait until force-shutdown the subscription during the stop process.

Returns:

  • (Integer)

    the number of seconds to wait until force-shutdown the subscription during the stop process



57
# File 'lib/pg_eventstore/config.rb', line 57

option(:subscription_graceful_shutdown_timeout) { 15 }

#subscription_max_retriesInteger

Returns max number of retries of failed Subscription.

Returns:

  • (Integer)

    max number of retries of failed Subscription



37
# File 'lib/pg_eventstore/config.rb', line 37

option(:subscription_max_retries) { 5 }

#subscription_pull_intervalFloat, Integer

Returns How often Subscription should pull new events, seconds.

Returns:

  • (Float, Integer)

    How often Subscription should pull new events, seconds



34
# File 'lib/pg_eventstore/config.rb', line 34

option(:subscription_pull_interval) { 1.0 }

#subscription_restart_terminator#call?

Returns provide callable object that accepts Subscription object to decide whether to prevent further Subscription restarts.

Returns:

  • (#call, nil)

    provide callable object that accepts Subscription object to decide whether to prevent further Subscription restarts



44
# File 'lib/pg_eventstore/config.rb', line 44

option(:subscription_restart_terminator)

#subscription_retries_intervalInteger

Returns interval in seconds between retries of failed Subscription.

Returns:

  • (Integer)

    interval in seconds between retries of failed Subscription



40
# File 'lib/pg_eventstore/config.rb', line 40

option(:subscription_retries_interval) { 1 }

#subscriptions_set_max_retriesInteger

Returns max number of retries of failed SubscriptionsSet.

Returns:

  • (Integer)

    max number of retries of failed SubscriptionsSet



47
# File 'lib/pg_eventstore/config.rb', line 47

option(:subscriptions_set_max_retries) { 10 }

#subscriptions_set_retries_intervalInteger

Returns interval in seconds between retries of failed SubscriptionsSet.

Returns:

  • (Integer)

    interval in seconds between retries of failed SubscriptionsSet



50
# File 'lib/pg_eventstore/config.rb', line 50

option(:subscriptions_set_retries_interval) { 1 }

Instance Method Details

#connection_optionsHash

Computes a value for usage in PgEventstore::Connection

Returns:

  • (Hash)


67
68
69
# File 'lib/pg_eventstore/config.rb', line 67

def connection_options
  { uri: pg_uri, pool_size: connection_pool_size, pool_timeout: connection_pool_timeout }
end