Class: JetstreamBridge::Core::ConnectionFactory::ConnectionOptions
- Inherits:
-
Object
- Object
- JetstreamBridge::Core::ConnectionFactory::ConnectionOptions
- Defined in:
- lib/jetstream_bridge/core/connection_factory.rb
Overview
Connection options builder
Constant Summary collapse
- DEFAULT_OPTS =
{ reconnect: true, reconnect_time_wait: 2, max_reconnect_attempts: 10, connect_timeout: 5 }.freeze
Instance Attribute Summary collapse
-
#additional_opts ⇒ Object
readonly
Returns the value of attribute additional_opts.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#max_reconnect_attempts ⇒ Object
Returns the value of attribute max_reconnect_attempts.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#reconnect ⇒ Object
Returns the value of attribute reconnect.
-
#reconnect_time_wait ⇒ Object
Returns the value of attribute reconnect_time_wait.
-
#servers ⇒ Object
Returns the value of attribute servers.
-
#token ⇒ Object
Returns the value of attribute token.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(servers: nil, **opts) ⇒ ConnectionOptions
constructor
A new instance of ConnectionOptions.
- #to_h ⇒ Object
Constructor Details
#initialize(servers: nil, **opts) ⇒ ConnectionOptions
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 24 def initialize(servers: nil, **opts) @servers = normalize_servers(servers) if servers @additional_opts = {} DEFAULT_OPTS.merge(opts).each do |key, value| if respond_to?(:"#{key}=") send(:"#{key}=", value) else @additional_opts[key] = value end end end |
Instance Attribute Details
#additional_opts ⇒ Object (readonly)
Returns the value of attribute additional_opts.
22 23 24 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 22 def additional_opts @additional_opts end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def connect_timeout @connect_timeout end |
#max_reconnect_attempts ⇒ Object
Returns the value of attribute max_reconnect_attempts.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def max_reconnect_attempts @max_reconnect_attempts end |
#name ⇒ Object
Returns the value of attribute name.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def name @name end |
#pass ⇒ Object
Returns the value of attribute pass.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def pass @pass end |
#reconnect ⇒ Object
Returns the value of attribute reconnect.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def reconnect @reconnect end |
#reconnect_time_wait ⇒ Object
Returns the value of attribute reconnect_time_wait.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def reconnect_time_wait @reconnect_time_wait end |
#servers ⇒ Object
Returns the value of attribute servers.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def servers @servers end |
#token ⇒ Object
Returns the value of attribute token.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def token @token end |
#user ⇒ Object
Returns the value of attribute user.
19 20 21 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 19 def user @user end |
Class Method Details
.build(opts = {}) ⇒ Object
37 38 39 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 37 def self.build(opts = {}) new(**opts) end |
Instance Method Details
#to_h ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/jetstream_bridge/core/connection_factory.rb', line 41 def to_h base = { reconnect: @reconnect, reconnect_time_wait: @reconnect_time_wait, max_reconnect_attempts: @max_reconnect_attempts, connect_timeout: @connect_timeout } base[:servers] = @servers if @servers base[:name] = @name if @name base[:user] = @user if @user base[:pass] = @pass if @pass base[:token] = @token if @token base.merge(@additional_opts) end |