Class: FeatBit::Options
- Inherits:
-
Object
- Object
- FeatBit::Options
- Defined in:
- lib/featbit/options.rb
Constant Summary collapse
- DEFAULT_STREAMING_URL =
"wss://app-eval.featbit.co"- DEFAULT_EVENT_URL =
"https://app-eval.featbit.co"
Instance Attribute Summary collapse
-
#bootstrap ⇒ Object
readonly
Returns the value of attribute bootstrap.
-
#connect_timeout ⇒ Object
readonly
Returns the value of attribute connect_timeout.
-
#data_store ⇒ Object
readonly
Returns the value of attribute data_store.
-
#disable_events ⇒ Object
readonly
Returns the value of attribute disable_events.
-
#env_secret ⇒ Object
readonly
Returns the value of attribute env_secret.
-
#event_processor_factory ⇒ Object
readonly
Returns the value of attribute event_processor_factory.
-
#event_url ⇒ Object
readonly
Returns the value of attribute event_url.
-
#events_batch_size ⇒ Object
readonly
Returns the value of attribute events_batch_size.
-
#events_capacity ⇒ Object
readonly
Returns the value of attribute events_capacity.
-
#events_flush_interval ⇒ Object
readonly
Returns the value of attribute events_flush_interval.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#offline ⇒ Object
readonly
Returns the value of attribute offline.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#reconnect_delay ⇒ Object
readonly
Returns the value of attribute reconnect_delay.
-
#start_wait ⇒ Object
readonly
Returns the value of attribute start_wait.
-
#streaming_url ⇒ Object
readonly
Returns the value of attribute streaming_url.
-
#synchronizer_factory ⇒ Object
readonly
Returns the value of attribute synchronizer_factory.
Instance Method Summary collapse
- #events_uri ⇒ Object
-
#initialize(env_secret: "", streaming_url: DEFAULT_STREAMING_URL, event_url: DEFAULT_EVENT_URL, start_wait: 5.0, offline: false, bootstrap: nil, disable_events: false, logger: nil, events_capacity: 10_000, events_flush_interval: 1.0, events_batch_size: 50, connect_timeout: 5.0, read_timeout: 10.0, reconnect_delay: 1.0, data_store: nil, synchronizer_factory: nil, event_processor_factory: nil) ⇒ Options
constructor
A new instance of Options.
- #streaming_uri ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(env_secret: "", streaming_url: DEFAULT_STREAMING_URL, event_url: DEFAULT_EVENT_URL, start_wait: 5.0, offline: false, bootstrap: nil, disable_events: false, logger: nil, events_capacity: 10_000, events_flush_interval: 1.0, events_batch_size: 50, connect_timeout: 5.0, read_timeout: 10.0, reconnect_delay: 1.0, data_store: nil, synchronizer_factory: nil, event_processor_factory: nil) ⇒ Options
Returns a new instance of Options.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/featbit/options.rb', line 17 def initialize(env_secret: "", streaming_url: DEFAULT_STREAMING_URL, event_url: DEFAULT_EVENT_URL, start_wait: 5.0, offline: false, bootstrap: nil, disable_events: false, logger: nil, events_capacity: 10_000, events_flush_interval: 1.0, events_batch_size: 50, connect_timeout: 5.0, read_timeout: 10.0, reconnect_delay: 1.0, data_store: nil, synchronizer_factory: nil, event_processor_factory: nil) @env_secret = env_secret.to_s @streaming_url = normalize_url(streaming_url) @event_url = normalize_url(event_url) @start_wait = positive_number(start_wait, 5.0) @offline = offline == true @bootstrap = bootstrap @disable_events = disable_events == true @logger = logger || Logger.new($stderr, level: Logger::WARN) @events_capacity = positive_integer(events_capacity, 10_000) @events_flush_interval = positive_number(events_flush_interval, 1.0) @events_batch_size = positive_integer(events_batch_size, 50) @connect_timeout = positive_number(connect_timeout, 5.0) @read_timeout = positive_number(read_timeout, 10.0) @reconnect_delay = positive_number(reconnect_delay, 1.0) @data_store = data_store @synchronizer_factory = synchronizer_factory @event_processor_factory = event_processor_factory freeze rescue StandardError => e warn("FeatBit options error: #{e.}") @env_secret = "" @streaming_url = DEFAULT_STREAMING_URL @event_url = DEFAULT_EVENT_URL @start_wait = 5.0 @offline = true @bootstrap = nil @disable_events = true @logger = Logger.new($stderr, level: Logger::WARN) @events_capacity = 10_000 @events_flush_interval = 1.0 @events_batch_size = 50 @connect_timeout = 5.0 @read_timeout = 10.0 @reconnect_delay = 1.0 freeze end |
Instance Attribute Details
#bootstrap ⇒ Object (readonly)
Returns the value of attribute bootstrap.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def bootstrap @bootstrap end |
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def connect_timeout @connect_timeout end |
#data_store ⇒ Object (readonly)
Returns the value of attribute data_store.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def data_store @data_store end |
#disable_events ⇒ Object (readonly)
Returns the value of attribute disable_events.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def disable_events @disable_events end |
#env_secret ⇒ Object (readonly)
Returns the value of attribute env_secret.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def env_secret @env_secret end |
#event_processor_factory ⇒ Object (readonly)
Returns the value of attribute event_processor_factory.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def event_processor_factory @event_processor_factory end |
#event_url ⇒ Object (readonly)
Returns the value of attribute event_url.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def event_url @event_url end |
#events_batch_size ⇒ Object (readonly)
Returns the value of attribute events_batch_size.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def events_batch_size @events_batch_size end |
#events_capacity ⇒ Object (readonly)
Returns the value of attribute events_capacity.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def events_capacity @events_capacity end |
#events_flush_interval ⇒ Object (readonly)
Returns the value of attribute events_flush_interval.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def events_flush_interval @events_flush_interval end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def logger @logger end |
#offline ⇒ Object (readonly)
Returns the value of attribute offline.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def offline @offline end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def read_timeout @read_timeout end |
#reconnect_delay ⇒ Object (readonly)
Returns the value of attribute reconnect_delay.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def reconnect_delay @reconnect_delay end |
#start_wait ⇒ Object (readonly)
Returns the value of attribute start_wait.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def start_wait @start_wait end |
#streaming_url ⇒ Object (readonly)
Returns the value of attribute streaming_url.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def streaming_url @streaming_url end |
#synchronizer_factory ⇒ Object (readonly)
Returns the value of attribute synchronizer_factory.
11 12 13 |
# File 'lib/featbit/options.rb', line 11 def synchronizer_factory @synchronizer_factory end |
Instance Method Details
#events_uri ⇒ Object
66 67 68 |
# File 'lib/featbit/options.rb', line 66 def events_uri append_path(event_url, "/api/public/insight/track") end |
#streaming_uri ⇒ Object
62 63 64 |
# File 'lib/featbit/options.rb', line 62 def streaming_uri append_path(streaming_url, "/streaming") end |
#valid? ⇒ Boolean
70 71 72 73 74 75 76 |
# File 'lib/featbit/options.rb', line 70 def valid? return true if offline !env_secret.empty? && valid_uri?(streaming_uri, %w[ws wss]) && valid_uri?(events_uri, %w[http https]) rescue StandardError false end |