splitclient-rb 5.1.0 → 5.1.1.pre.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +9 -5
- data/Detailed-README.md +1 -1
- data/exe/splitio +6 -6
- data/lib/splitclient-rb/cache/repositories/events/memory_repository.rb +3 -4
- data/lib/splitclient-rb/cache/repositories/events/redis_repository.rb +1 -2
- data/lib/splitclient-rb/cache/repositories/events_repository.rb +6 -7
- data/lib/splitclient-rb/cache/repositories/impressions/memory_repository.rb +6 -7
- data/lib/splitclient-rb/cache/repositories/impressions/redis_repository.rb +9 -10
- data/lib/splitclient-rb/cache/repositories/impressions_repository.rb +3 -4
- data/lib/splitclient-rb/cache/repositories/metrics/memory_repository.rb +1 -3
- data/lib/splitclient-rb/cache/repositories/metrics/redis_repository.rb +1 -2
- data/lib/splitclient-rb/cache/repositories/metrics_repository.rb +3 -4
- data/lib/splitclient-rb/cache/repositories/repository.rb +2 -2
- data/lib/splitclient-rb/cache/repositories/segments_repository.rb +1 -3
- data/lib/splitclient-rb/cache/repositories/splits_repository.rb +1 -3
- data/lib/splitclient-rb/cache/routers/impression_router.rb +4 -5
- data/lib/splitclient-rb/cache/senders/events_sender.rb +6 -7
- data/lib/splitclient-rb/cache/senders/impressions_sender.rb +8 -9
- data/lib/splitclient-rb/cache/senders/metrics_sender.rb +6 -7
- data/lib/splitclient-rb/cache/stores/sdk_blocker.rb +3 -4
- data/lib/splitclient-rb/cache/stores/segment_store.rb +11 -12
- data/lib/splitclient-rb/cache/stores/split_store.rb +12 -13
- data/lib/splitclient-rb/clients/localhost_split_client.rb +2 -2
- data/lib/splitclient-rb/clients/split_client.rb +15 -17
- data/lib/splitclient-rb/engine/api/client.rb +22 -22
- data/lib/splitclient-rb/engine/api/events.rb +6 -8
- data/lib/splitclient-rb/engine/api/impressions.rb +5 -6
- data/lib/splitclient-rb/engine/api/metrics.rb +8 -9
- data/lib/splitclient-rb/engine/api/segments.rb +2 -3
- data/lib/splitclient-rb/engine/api/splits.rb +2 -3
- data/lib/splitclient-rb/engine/metrics/metrics.rb +1 -4
- data/lib/splitclient-rb/engine/parser/split_adapter.rb +8 -10
- data/lib/splitclient-rb/managers/split_manager.rb +1 -2
- data/lib/splitclient-rb/split_config.rb +47 -38
- data/lib/splitclient-rb/split_factory.rb +13 -14
- data/lib/splitclient-rb/split_logger.rb +3 -8
- data/lib/splitclient-rb/version.rb +1 -1
- data/splitclient-rb.gemspec +1 -1
- metadata +8 -8
@@ -2,9 +2,8 @@ module SplitIoClient
|
|
2
2
|
module Cache
|
3
3
|
module Senders
|
4
4
|
class MetricsSender
|
5
|
-
def initialize(metrics_repository,
|
5
|
+
def initialize(metrics_repository, api_key)
|
6
6
|
@metrics_repository = metrics_repository
|
7
|
-
@config = config
|
8
7
|
@api_key = api_key
|
9
8
|
end
|
10
9
|
|
@@ -23,13 +22,13 @@ module SplitIoClient
|
|
23
22
|
private
|
24
23
|
|
25
24
|
def metrics_thread
|
26
|
-
|
27
|
-
|
25
|
+
SplitIoClient.configuration.threads[:metrics_sender] = Thread.new do
|
26
|
+
SplitIoClient.configuration.logger.info('Starting metrics service')
|
28
27
|
|
29
28
|
loop do
|
30
29
|
post_metrics
|
31
30
|
|
32
|
-
sleep(SplitIoClient::Utilities.randomize_interval(
|
31
|
+
sleep(SplitIoClient::Utilities.randomize_interval(SplitIoClient.configuration.metrics_refresh_rate))
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -37,11 +36,11 @@ module SplitIoClient
|
|
37
36
|
def post_metrics
|
38
37
|
metrics_client.post
|
39
38
|
rescue StandardError => error
|
40
|
-
|
39
|
+
SplitIoClient.configuration.log_found_exception(__method__.to_s, error)
|
41
40
|
end
|
42
41
|
|
43
42
|
def metrics_client
|
44
|
-
SplitIoClient::Api::Metrics.new(@api_key, @
|
43
|
+
SplitIoClient::Api::Metrics.new(@api_key, @metrics_repository)
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
@@ -8,8 +8,7 @@ module SplitIoClient
|
|
8
8
|
attr_reader :splits_repository
|
9
9
|
attr_writer :splits_thread, :segments_thread
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@config = config
|
11
|
+
def initialize(splits_repository, segments_repository)
|
13
12
|
@splits_repository = splits_repository
|
14
13
|
@segments_repository = segments_repository
|
15
14
|
|
@@ -27,14 +26,14 @@ module SplitIoClient
|
|
27
26
|
|
28
27
|
def block
|
29
28
|
begin
|
30
|
-
Timeout::timeout(
|
29
|
+
Timeout::timeout(SplitIoClient.configuration.block_until_ready) do
|
31
30
|
sleep 0.1 until ready?
|
32
31
|
end
|
33
32
|
rescue Timeout::Error
|
34
33
|
fail SDKBlockerTimeoutExpiredException, 'SDK start up timeout expired'
|
35
34
|
end
|
36
35
|
|
37
|
-
|
36
|
+
SplitIoClient.configuration.logger.info('SplitIO SDK is ready')
|
38
37
|
@splits_thread.run
|
39
38
|
@segments_thread.run
|
40
39
|
end
|
@@ -4,9 +4,8 @@ module SplitIoClient
|
|
4
4
|
class SegmentStore
|
5
5
|
attr_reader :segments_repository
|
6
6
|
|
7
|
-
def initialize(segments_repository,
|
7
|
+
def initialize(segments_repository, api_key, metrics, sdk_blocker = nil)
|
8
8
|
@segments_repository = segments_repository
|
9
|
-
@config = config
|
10
9
|
@api_key = api_key
|
11
10
|
@metrics = metrics
|
12
11
|
@sdk_blocker = sdk_blocker
|
@@ -29,9 +28,9 @@ module SplitIoClient
|
|
29
28
|
private
|
30
29
|
|
31
30
|
def segments_thread
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
SplitIoClient.configuration.threads[:segment_store] = @sdk_blocker.segments_thread = Thread.new do
|
32
|
+
SplitIoClient.configuration.logger.info('Starting segments fetcher service')
|
33
|
+
SplitIoClient.configuration.block_until_ready > 0 ? blocked_store : unblocked_store
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
@@ -40,15 +39,15 @@ module SplitIoClient
|
|
40
39
|
next unless @sdk_blocker.splits_repository.ready?
|
41
40
|
|
42
41
|
store_segments
|
43
|
-
|
42
|
+
SplitIoClient.configuration.logger.debug("Segment names: #{@segments_repository.used_segment_names.to_a}") if SplitIoClient.configuration.debug_enabled
|
44
43
|
|
45
44
|
unless @sdk_blocker.ready?
|
46
45
|
@sdk_blocker.segments_ready!
|
47
|
-
|
46
|
+
SplitIoClient.configuration.logger.info('segments are ready')
|
48
47
|
end
|
49
48
|
|
50
|
-
sleep_for = random_interval(
|
51
|
-
|
49
|
+
sleep_for = random_interval(SplitIoClient.configuration.segments_refresh_rate)
|
50
|
+
SplitIoClient.configuration.logger.debug("Segments store is sleeping for: #{sleep_for} seconds") if SplitIoClient.configuration.debug_enabled
|
52
51
|
sleep(sleep_for)
|
53
52
|
end
|
54
53
|
end
|
@@ -57,14 +56,14 @@ module SplitIoClient
|
|
57
56
|
loop do
|
58
57
|
store_segments
|
59
58
|
|
60
|
-
sleep(random_interval(
|
59
|
+
sleep(random_interval(SplitIoClient.configuration.segments_refresh_rate))
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
63
|
def store_segments
|
65
64
|
segments_api.store_segments_by_names(@segments_repository.used_segment_names)
|
66
65
|
rescue StandardError => error
|
67
|
-
|
66
|
+
SplitIoClient.configuration.log_found_exception(__method__.to_s, error)
|
68
67
|
end
|
69
68
|
|
70
69
|
def random_interval(interval)
|
@@ -74,7 +73,7 @@ module SplitIoClient
|
|
74
73
|
end
|
75
74
|
|
76
75
|
def segments_api
|
77
|
-
SplitIoClient::Api::Segments.new(@api_key, @
|
76
|
+
SplitIoClient::Api::Segments.new(@api_key, @metrics, @segments_repository)
|
78
77
|
end
|
79
78
|
end
|
80
79
|
end
|
@@ -4,9 +4,8 @@ module SplitIoClient
|
|
4
4
|
class SplitStore
|
5
5
|
attr_reader :splits_repository
|
6
6
|
|
7
|
-
def initialize(splits_repository,
|
7
|
+
def initialize(splits_repository, api_key, metrics, sdk_blocker = nil)
|
8
8
|
@splits_repository = splits_repository
|
9
|
-
@config = config
|
10
9
|
@api_key = api_key
|
11
10
|
@metrics = metrics
|
12
11
|
@sdk_blocker = sdk_blocker
|
@@ -29,12 +28,12 @@ module SplitIoClient
|
|
29
28
|
private
|
30
29
|
|
31
30
|
def splits_thread
|
32
|
-
|
33
|
-
|
31
|
+
SplitIoClient.configuration.threads[:split_store] = @sdk_blocker.splits_thread = Thread.new do
|
32
|
+
SplitIoClient.configuration.logger.info('Starting splits fetcher service')
|
34
33
|
loop do
|
35
34
|
store_splits
|
36
35
|
|
37
|
-
sleep(random_interval(
|
36
|
+
sleep(random_interval(SplitIoClient.configuration.features_refresh_rate))
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
@@ -49,15 +48,15 @@ module SplitIoClient
|
|
49
48
|
@splits_repository.set_segment_names(data[:segment_names])
|
50
49
|
@splits_repository.set_change_number(data[:till])
|
51
50
|
|
52
|
-
|
51
|
+
SplitIoClient.configuration.logger.debug("segments seen(#{data[:segment_names].length}): #{data[:segment_names].to_a}") if SplitIoClient.configuration.debug_enabled
|
53
52
|
|
54
|
-
if
|
53
|
+
if SplitIoClient.configuration.block_until_ready > 0 && !@sdk_blocker.ready?
|
55
54
|
@sdk_blocker.splits_ready!
|
56
|
-
|
55
|
+
SplitIoClient.configuration.logger.info('splits are ready')
|
57
56
|
end
|
58
57
|
|
59
58
|
rescue StandardError => error
|
60
|
-
|
59
|
+
SplitIoClient.configuration.log_found_exception(__method__.to_s, error)
|
61
60
|
end
|
62
61
|
|
63
62
|
def random_interval(interval)
|
@@ -67,12 +66,12 @@ module SplitIoClient
|
|
67
66
|
end
|
68
67
|
|
69
68
|
def splits_since(since)
|
70
|
-
SplitIoClient::Api::Splits.new(@api_key, @
|
69
|
+
SplitIoClient::Api::Splits.new(@api_key, @metrics).since(since)
|
71
70
|
end
|
72
71
|
|
73
72
|
def add_split_unless_archived(split)
|
74
73
|
if Engine::Models::Split.archived?(split)
|
75
|
-
|
74
|
+
SplitIoClient.configuration.logger.debug("Seeing archived split #{split[:name]}") if SplitIoClient.configuration.debug_enabled
|
76
75
|
|
77
76
|
remove_archived_split(split)
|
78
77
|
else
|
@@ -81,13 +80,13 @@ module SplitIoClient
|
|
81
80
|
end
|
82
81
|
|
83
82
|
def remove_archived_split(split)
|
84
|
-
|
83
|
+
SplitIoClient.configuration.logger.debug("removing split from store(#{split})") if SplitIoClient.configuration.debug_enabled
|
85
84
|
|
86
85
|
@splits_repository.remove_split(split[:name])
|
87
86
|
end
|
88
87
|
|
89
88
|
def store_split(split)
|
90
|
-
|
89
|
+
SplitIoClient.configuration.logger.debug("storing split (#{split[:name]})") if SplitIoClient.configuration.debug_enabled
|
91
90
|
|
92
91
|
@splits_repository.add_split(split)
|
93
92
|
end
|
@@ -42,12 +42,12 @@ module SplitIoClient
|
|
42
42
|
# @return [Treatment] treatment constant value
|
43
43
|
def get_treatment(id, feature, attributes = nil)
|
44
44
|
unless id
|
45
|
-
|
45
|
+
SplitIoClient.configuration.logger.warn('id was null for feature: ' + feature)
|
46
46
|
return SplitIoClient::Engine::Models::Treatment::CONTROL
|
47
47
|
end
|
48
48
|
|
49
49
|
unless feature
|
50
|
-
|
50
|
+
SplitIoClient.configuration.logger.warn('feature was null for id: ' + id)
|
51
51
|
return SplitIoClient::Engine::Models::Treatment::CONTROL
|
52
52
|
end
|
53
53
|
|
@@ -6,9 +6,7 @@ module SplitIoClient
|
|
6
6
|
# @param api_key [String] the API key for your split account
|
7
7
|
#
|
8
8
|
# @return [SplitIoClient] split.io client instance
|
9
|
-
def initialize(api_key,
|
10
|
-
@config = config
|
11
|
-
|
9
|
+
def initialize(api_key, adapter = nil, splits_repository, segments_repository, impressions_repository, metrics_repository, events_repository)
|
12
10
|
@splits_repository = splits_repository
|
13
11
|
@segments_repository = segments_repository
|
14
12
|
@impressions_repository = impressions_repository
|
@@ -27,7 +25,7 @@ module SplitIoClient
|
|
27
25
|
memo.merge!(name => get_treatment(key, name, attributes, data, false, true, evaluator))
|
28
26
|
end
|
29
27
|
|
30
|
-
unless
|
28
|
+
unless SplitIoClient.configuration.disable_impressions
|
31
29
|
time = (Time.now.to_f * 1000.0).to_i
|
32
30
|
@impressions_repository.add_bulk(
|
33
31
|
matching_key, bucketing_key, treatments_labels_change_numbers, time
|
@@ -63,12 +61,12 @@ module SplitIoClient
|
|
63
61
|
evaluator ||= Engine::Parser::Evaluator.new(@segments_repository, @splits_repository)
|
64
62
|
|
65
63
|
if matching_key.nil?
|
66
|
-
|
64
|
+
SplitIoClient.configuration.logger.warn('matching_key was null for split_name: ' + split_name.to_s)
|
67
65
|
return parsed_treatment(multiple, treatment_data)
|
68
66
|
end
|
69
67
|
|
70
68
|
if split_name.nil?
|
71
|
-
|
69
|
+
SplitIoClient.configuration.logger.warn('split_name was null for key: ' + key)
|
72
70
|
return parsed_treatment(multiple, treatment_data)
|
73
71
|
end
|
74
72
|
|
@@ -78,7 +76,7 @@ module SplitIoClient
|
|
78
76
|
split = multiple ? split_data : @splits_repository.get_split(split_name)
|
79
77
|
|
80
78
|
if split.nil?
|
81
|
-
|
79
|
+
SplitIoClient.configuration.logger.debug("split_name: #{split_name} does not exist. Returning CONTROL")
|
82
80
|
return parsed_treatment(multiple, treatment_data)
|
83
81
|
else
|
84
82
|
treatment_data =
|
@@ -87,7 +85,7 @@ module SplitIoClient
|
|
87
85
|
)
|
88
86
|
end
|
89
87
|
rescue StandardError => error
|
90
|
-
|
88
|
+
SplitIoClient.configuration.log_found_exception(__method__.to_s, error)
|
91
89
|
|
92
90
|
store_impression(
|
93
91
|
split_name, matching_key, bucketing_key,
|
@@ -108,7 +106,7 @@ module SplitIoClient
|
|
108
106
|
# Measure
|
109
107
|
@adapter.metrics.time('sdk.get_treatment', latency)
|
110
108
|
rescue StandardError => error
|
111
|
-
|
109
|
+
SplitIoClient.configuration.log_found_exception(__method__.to_s, error)
|
112
110
|
|
113
111
|
store_impression(
|
114
112
|
split_name, matching_key, bucketing_key,
|
@@ -126,10 +124,10 @@ module SplitIoClient
|
|
126
124
|
end
|
127
125
|
|
128
126
|
def destroy
|
129
|
-
|
127
|
+
SplitIoClient.configuration.logger.info('Split client shutdown started...') if SplitIoClient.configuration.debug_enabled
|
130
128
|
|
131
|
-
|
132
|
-
|
129
|
+
SplitIoClient.configuration.threads[:impressions_sender].raise(SplitIoClient::ImpressionShutdownException)
|
130
|
+
SplitIoClient.configuration.threads.reject { |k, _| k == :impressions_sender }.each do |name, thread|
|
133
131
|
Thread.kill(thread)
|
134
132
|
end
|
135
133
|
|
@@ -138,19 +136,19 @@ module SplitIoClient
|
|
138
136
|
@segments_repository.clear
|
139
137
|
@events_repository.clear
|
140
138
|
|
141
|
-
|
139
|
+
SplitIoClient.configuration.logger.info('Split client shutdown complete') if SplitIoClient.configuration.debug_enabled
|
142
140
|
end
|
143
141
|
|
144
142
|
def store_impression(split_name, matching_key, bucketing_key, treatment, store_impressions, attributes)
|
145
143
|
time = (Time.now.to_f * 1000.0).to_i
|
146
144
|
|
147
|
-
return if
|
145
|
+
return if SplitIoClient.configuration.disable_impressions || !store_impressions
|
148
146
|
|
149
147
|
@impressions_repository.add(split_name,
|
150
148
|
'keyName' => matching_key,
|
151
149
|
'bucketingKey' => bucketing_key,
|
152
150
|
'treatment' => treatment[:treatment],
|
153
|
-
'label' =>
|
151
|
+
'label' => SplitIoClient.configuration.labels_enabled ? treatment[:label] : nil,
|
154
152
|
'time' => time,
|
155
153
|
'changeNumber' => treatment[:change_number]
|
156
154
|
)
|
@@ -158,7 +156,7 @@ module SplitIoClient
|
|
158
156
|
route_impression(split_name, matching_key, bucketing_key, time, treatment, attributes)
|
159
157
|
|
160
158
|
rescue StandardError => error
|
161
|
-
|
159
|
+
SplitIoClient.configuration.log_found_exception(__method__.to_s, error)
|
162
160
|
end
|
163
161
|
|
164
162
|
def route_impression(split_name, matching_key, bucketing_key, time, treatment, attributes)
|
@@ -184,7 +182,7 @@ module SplitIoClient
|
|
184
182
|
end
|
185
183
|
|
186
184
|
def impression_router
|
187
|
-
@impression_router ||= SplitIoClient::ImpressionRouter.new
|
185
|
+
@impression_router ||= SplitIoClient::ImpressionRouter.new
|
188
186
|
end
|
189
187
|
|
190
188
|
def track(key, traffic_type, event_type, value = nil)
|
@@ -5,39 +5,39 @@ module SplitIoClient
|
|
5
5
|
class Client
|
6
6
|
RUBY_ENCODING = '1.9'.respond_to?(:force_encoding)
|
7
7
|
|
8
|
-
def get_api(url,
|
8
|
+
def get_api(url, api_key, params = {})
|
9
9
|
api_client.get(url, params) do |req|
|
10
|
-
req.headers = common_headers(api_key
|
10
|
+
req.headers = common_headers(api_key).merge('Accept-Encoding' => 'gzip')
|
11
11
|
|
12
|
-
req.options[:timeout] =
|
13
|
-
req.options[:open_timeout] =
|
12
|
+
req.options[:timeout] = SplitIoClient.configuration.read_timeout
|
13
|
+
req.options[:open_timeout] = SplitIoClient.configuration.connection_timeout
|
14
14
|
|
15
|
-
|
15
|
+
SplitIoClient.configuration.logger.debug("GET #{url} proxy: #{api_client.proxy}") if SplitIoClient.configuration.debug_enabled
|
16
16
|
end
|
17
17
|
rescue StandardError => e
|
18
|
-
|
18
|
+
SplitIoClient.configuration.logger.warn("#{e}\nURL:#{url}\nparams:#{params}")
|
19
19
|
raise 'Split SDK failed to connect to backend to retrieve information'
|
20
20
|
end
|
21
21
|
|
22
|
-
def post_api(url,
|
22
|
+
def post_api(url, api_key, data, headers = {}, params = {})
|
23
23
|
api_client.post(url) do |req|
|
24
|
-
req.headers = common_headers(api_key
|
24
|
+
req.headers = common_headers(api_key)
|
25
25
|
.merge('Content-Type' => 'application/json')
|
26
26
|
.merge(headers)
|
27
27
|
|
28
28
|
req.body = data.to_json
|
29
29
|
|
30
|
-
req.options[:timeout] =
|
31
|
-
req.options[:open_timeout] =
|
30
|
+
req.options[:timeout] = SplitIoClient.configuration.read_timeout
|
31
|
+
req.options[:open_timeout] = SplitIoClient.configuration.connection_timeout
|
32
32
|
|
33
|
-
if
|
34
|
-
|
35
|
-
elsif
|
36
|
-
|
33
|
+
if SplitIoClient.configuration.transport_debug_enabled
|
34
|
+
SplitIoClient.configuration.logger.debug("POST #{url} #{req.body}")
|
35
|
+
elsif SplitIoClient.configuration.debug_enabled
|
36
|
+
SplitIoClient.configuration.logger.debug("POST #{url}")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
rescue StandardError => e
|
40
|
-
|
40
|
+
SplitIoClient.configuration.logger.warn("#{e}\nURL:#{url}\ndata:#{data}\nparams:#{params}")
|
41
41
|
|
42
42
|
false
|
43
43
|
end
|
@@ -51,18 +51,18 @@ module SplitIoClient
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def common_headers(api_key
|
54
|
+
def common_headers(api_key)
|
55
55
|
{
|
56
56
|
'Authorization' => "Bearer #{api_key}",
|
57
|
-
'SplitSDKVersion' => "#{
|
58
|
-
'SplitSDKMachineName' =>
|
59
|
-
'SplitSDKMachineIP' =>
|
60
|
-
'Referer' => referer
|
57
|
+
'SplitSDKVersion' => "#{SplitIoClient.configuration.language}-#{SplitIoClient.configuration.version}",
|
58
|
+
'SplitSDKMachineName' => SplitIoClient.configuration.machine_name,
|
59
|
+
'SplitSDKMachineIP' => SplitIoClient.configuration.machine_ip,
|
60
|
+
'Referer' => referer
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
64
|
-
def referer
|
65
|
-
result = "#{
|
64
|
+
def referer
|
65
|
+
result = "#{SplitIoClient.configuration.language}-#{SplitIoClient.configuration.version}"
|
66
66
|
|
67
67
|
result = "#{result}::#{SplitIoClient::SplitConfig.machine_hostname}" unless SplitIoClient::SplitConfig.machine_hostname == 'localhost'
|
68
68
|
|
@@ -1,22 +1,20 @@
|
|
1
1
|
module SplitIoClient
|
2
2
|
module Api
|
3
3
|
class Events < Client
|
4
|
-
def initialize(api_key,
|
5
|
-
@config = config
|
4
|
+
def initialize(api_key, events)
|
6
5
|
@api_key = api_key
|
7
6
|
@events = events
|
8
7
|
end
|
9
8
|
|
10
9
|
def post
|
11
10
|
if @events.empty?
|
12
|
-
|
11
|
+
SplitIoClient.configuration.logger.debug('No events to report') if SplitIoClient.configuration.debug_enabled
|
13
12
|
return
|
14
13
|
end
|
15
14
|
|
16
|
-
@events.each_slice(
|
15
|
+
@events.each_slice(SplitIoClient.configuration.events_queue_size) do |event_slice|
|
17
16
|
result = post_api(
|
18
|
-
"#{
|
19
|
-
@config,
|
17
|
+
"#{SplitIoClient.configuration.events_uri}/events/bulk",
|
20
18
|
@api_key,
|
21
19
|
event_slice.map { |event| formatted_event(event[:e]) },
|
22
20
|
'SplitSDKMachineIP' => event_slice[0][:m][:i],
|
@@ -25,9 +23,9 @@ module SplitIoClient
|
|
25
23
|
)
|
26
24
|
|
27
25
|
if (200..299).include? result.status
|
28
|
-
|
26
|
+
SplitIoClient.configuration.logger.debug("Events reported: #{event_slice.size}") if SplitIoClient.configuration.debug_enabled
|
29
27
|
else
|
30
|
-
|
28
|
+
SplitIoClient.configuration.logger.error("Unexpected status code while posting events: #{result.status}")
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|