Class: ChatSDK::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/chat_sdk/config.rb

Constant Summary collapse

DEFAULTS =
{
  dedupe_ttl: 600,
  streaming_update_interval: 0.5,
  on_lock_conflict: :drop,
  handler_executor: :inline,
  log_level: :info
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_name:, adapters:, state:, **options) ⇒ Config

Returns a new instance of Config.

Raises:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/chat_sdk/config.rb', line 16

def initialize(user_name:, adapters:, state:, **options)
  raise ConfigurationError, "user_name is required" if user_name.nil? || user_name.empty?
  raise ConfigurationError, "adapters hash is required" if adapters.nil? || adapters.empty?
  raise ConfigurationError, "state adapter is required" if state.nil?

  @user_name = user_name
  @adapters = adapters
  @state = state
  merged = DEFAULTS.merge(options)
  @on_lock_conflict = merged[:on_lock_conflict]
  @dedupe_ttl = merged[:dedupe_ttl]
  @streaming_update_interval = merged[:streaming_update_interval]
  @handler_executor = merged[:handler_executor]
  @log_level = merged[:log_level]

  validate_lock_conflict!
end

Instance Attribute Details

#adaptersObject (readonly)

Returns the value of attribute adapters.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def adapters
  @adapters
end

#dedupe_ttlObject (readonly)

Returns the value of attribute dedupe_ttl.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def dedupe_ttl
  @dedupe_ttl
end

#handler_executorObject (readonly)

Returns the value of attribute handler_executor.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def handler_executor
  @handler_executor
end

#log_levelObject (readonly)

Returns the value of attribute log_level.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def log_level
  @log_level
end

#on_lock_conflictObject (readonly)

Returns the value of attribute on_lock_conflict.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def on_lock_conflict
  @on_lock_conflict
end

#stateObject (readonly)

Returns the value of attribute state.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def state
  @state
end

#streaming_update_intervalObject (readonly)

Returns the value of attribute streaming_update_interval.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def streaming_update_interval
  @streaming_update_interval
end

#user_nameObject (readonly)

Returns the value of attribute user_name.



13
14
15
# File 'lib/chat_sdk/config.rb', line 13

def user_name
  @user_name
end