Exception: SplitIoClient::SplitAdapter
- Inherits:
-
NoMethodError
- Object
- NoMethodError
- SplitIoClient::SplitAdapter
- Defined in:
- lib/splitclient-rb/engine/parser/split_adapter.rb
Overview
acts as an api adapater to connect to split endpoints uses a configuration object that can be modified when creating the client instance also, uses safe threads to execute fetches and post give the time execution values from the config
Instance Attribute Summary collapse
-
#impressions_repository ⇒ Object
readonly
Returns the value of attribute impressions_repository.
-
#metrics ⇒ Object
readonly
Returns the value of attribute metrics.
-
#segments_repository ⇒ Object
readonly
Returns the value of attribute segments_repository.
-
#splits_repository ⇒ Object
readonly
Returns the value of attribute splits_repository.
Instance Method Summary collapse
-
#events_sender ⇒ Object
Starts thread which loops constantly and sends events to the Split API.
-
#impressions_sender ⇒ Object
Starts thread which loops constantly and sends impressions to the Split API.
-
#initialize(api_key, config, splits_repository, segments_repository, impressions_repository, metrics_repository, events_repository, sdk_blocker) ⇒ SplitIoClient
constructor
Creates a new split api adapter instance that consumes split api endpoints.
-
#metrics_sender ⇒ Object
Starts thread which loops constantly and sends metrics to the Split API.
-
#segment_store ⇒ Object
Starts thread which loops constantly and stores segments in the segments_repository of choice.
-
#split_store ⇒ Object
Starts thread which loops constantly and stores splits in the splits_repository of choice.
- #start_based_on_mode(mode) ⇒ Object
Constructor Details
#initialize(api_key, config, splits_repository, segments_repository, impressions_repository, metrics_repository, events_repository, sdk_blocker) ⇒ SplitIoClient
Creates a new split api adapter instance that consumes split api endpoints
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 28 def initialize(api_key, config, splits_repository, segments_repository, impressions_repository, metrics_repository, events_repository, sdk_blocker) @api_key = api_key @config = config @splits_repository = splits_repository @segments_repository = segments_repository @impressions_repository = impressions_repository @metrics_repository = metrics_repository @events_repository = events_repository @metrics = Metrics.new(100, @config, @metrics_repository) @sdk_blocker = sdk_blocker start_based_on_mode(@config.mode) end |
Instance Attribute Details
#impressions_repository ⇒ Object (readonly)
Returns the value of attribute impressions_repository.
14 15 16 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 14 def impressions_repository @impressions_repository end |
#metrics ⇒ Object (readonly)
Returns the value of attribute metrics.
14 15 16 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 14 def metrics @metrics end |
#segments_repository ⇒ Object (readonly)
Returns the value of attribute segments_repository.
14 15 16 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 14 def segments_repository @segments_repository end |
#splits_repository ⇒ Object (readonly)
Returns the value of attribute splits_repository.
14 15 16 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 14 def splits_repository @splits_repository end |
Instance Method Details
#events_sender ⇒ Object
Starts thread which loops constantly and sends events to the Split API
84 85 86 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 84 def events_sender EventsSender.new(@events_repository, @config, @api_key).call end |
#impressions_sender ⇒ Object
Starts thread which loops constantly and sends impressions to the Split API
74 75 76 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 74 def impressions_sender ImpressionsSender.new(@impressions_repository, @config, @api_key).call end |
#metrics_sender ⇒ Object
Starts thread which loops constantly and sends metrics to the Split API
79 80 81 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 79 def metrics_sender MetricsSender.new(@metrics_repository, @config, @api_key).call end |
#segment_store ⇒ Object
Starts thread which loops constantly and stores segments in the segments_repository of choice
69 70 71 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 69 def segment_store SegmentStore.new(@segments_repository, @config, @api_key, @metrics, @sdk_blocker).call end |
#split_store ⇒ Object
Starts thread which loops constantly and stores splits in the splits_repository of choice
64 65 66 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 64 def split_store SplitStore.new(@splits_repository, @config, @api_key, @metrics, @sdk_blocker).call end |
#start_based_on_mode(mode) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/splitclient-rb/engine/parser/split_adapter.rb', line 42 def start_based_on_mode(mode) case mode when :standalone split_store segment_store metrics_sender impressions_sender events_sender when :consumer # Do nothing in background when :producer split_store segment_store impressions_sender metrics_sender events_sender sleep unless ENV['SPLITCLIENT_ENV'] == 'test' end end |