splitclient-rb 7.3.5.pre.rc3-java → 8.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +8 -10
- data/.rubocop.yml +19 -15
- data/CHANGES.txt +7 -0
- data/README.md +2 -2
- data/Rakefile +1 -8
- data/lib/splitclient-rb/cache/fetchers/segment_fetcher.rb +6 -6
- data/lib/splitclient-rb/cache/fetchers/split_fetcher.rb +2 -2
- data/lib/splitclient-rb/cache/repositories/events/memory_repository.rb +2 -2
- data/lib/splitclient-rb/cache/repositories/events_repository.rb +2 -2
- data/lib/splitclient-rb/cache/repositories/segments_repository.rb +2 -2
- data/lib/splitclient-rb/cache/routers/impression_router.rb +4 -4
- data/lib/splitclient-rb/cache/senders/impressions_adapter/memory_sender.rb +6 -6
- data/lib/splitclient-rb/cache/senders/impressions_adapter/redis_sender.rb +2 -4
- data/lib/splitclient-rb/cache/senders/impressions_count_sender.rb +3 -3
- data/lib/splitclient-rb/cache/senders/impressions_sender.rb +2 -2
- data/lib/splitclient-rb/cache/stores/localhost_split_store.rb +2 -2
- data/lib/splitclient-rb/clients/split_client.rb +4 -4
- data/lib/splitclient-rb/engine/api/client.rb +0 -23
- data/lib/splitclient-rb/engine/api/telemetry_api.rb +2 -2
- data/lib/splitclient-rb/engine/auth_api_client.rb +2 -2
- data/lib/splitclient-rb/engine/common/impressions_manager.rb +8 -4
- data/lib/splitclient-rb/engine/matchers/contains_all_matcher.rb +0 -4
- data/lib/splitclient-rb/engine/matchers/contains_any_matcher.rb +0 -4
- data/lib/splitclient-rb/engine/matchers/equal_to_set_matcher.rb +0 -4
- data/lib/splitclient-rb/engine/matchers/part_of_set_matcher.rb +0 -4
- data/lib/splitclient-rb/engine/push_manager.rb +14 -11
- data/lib/splitclient-rb/engine/synchronizer.rb +4 -4
- data/lib/splitclient-rb/split_config.rb +6 -4
- data/lib/splitclient-rb/split_factory.rb +4 -5
- data/lib/splitclient-rb/sse/notification_manager_keeper.rb +3 -2
- data/lib/splitclient-rb/telemetry/memory/memory_evaluation_consumer.rb +1 -1
- data/lib/splitclient-rb/telemetry/memory/memory_evaluation_producer.rb +5 -5
- data/lib/splitclient-rb/telemetry/memory/memory_init_consumer.rb +1 -1
- data/lib/splitclient-rb/telemetry/memory/memory_init_producer.rb +5 -5
- data/lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb +1 -1
- data/lib/splitclient-rb/telemetry/memory/memory_runtime_producer.rb +20 -20
- data/lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb +5 -5
- data/lib/splitclient-rb/telemetry/redis/redis_evaluation_producer.rb +1 -1
- data/lib/splitclient-rb/telemetry/redis/redis_init_producer.rb +7 -7
- data/lib/splitclient-rb/telemetry/redis/redis_synchronizer.rb +3 -3
- data/lib/splitclient-rb/telemetry/sync_task.rb +11 -11
- data/lib/splitclient-rb/version.rb +1 -1
- data/lib/splitclient-rb.rb +0 -1
- data/splitclient-rb.gemspec +6 -7
- metadata +26 -28
- data/Appraisals +0 -10
- data/lib/splitclient-rb/engine/api/faraday_adapter/patched_net_http_persistent.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2128b5a5f0a81e696c26924a12bac52759201bef
|
4
|
+
data.tar.gz: 56dec10fff8a05840b779473b91965525fbefcbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d503d6990730dc6b009ef97637f136b6d043891456204528bde156b451dcf6ca41d37cb7a9dd7c58d7ae137953f49fd7b73914a556c617f6fd9ef706e83b515
|
7
|
+
data.tar.gz: 9fa60bb60e3e900381cf1882dc086cf6f96d04862f48ccb32f41e6ac6cc1ff62655f599d14402c9636889145f1479322fccc1c6c3b8007f3b20e1106f62b0c44
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
on:
|
2
|
-
push:
|
3
|
-
branches:
|
4
|
-
- master
|
5
|
-
pull_request:
|
6
|
-
branches:
|
7
|
-
- master
|
1
|
+
on: [push, pull_request]
|
8
2
|
|
9
3
|
jobs:
|
10
4
|
test:
|
@@ -14,16 +8,20 @@ jobs:
|
|
14
8
|
image: redis
|
15
9
|
ports:
|
16
10
|
- 6379:6379
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
ruby: [ '2.5.0', '3.1.1' ]
|
14
|
+
|
17
15
|
steps:
|
18
16
|
- name: Checkout code
|
19
17
|
uses: actions/checkout@v2
|
20
18
|
with:
|
21
19
|
fetch-depth: 0
|
22
20
|
|
23
|
-
- name: Set up Ruby
|
24
|
-
uses: ruby/setup-ruby@
|
21
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
22
|
+
uses: ruby/setup-ruby@v1
|
25
23
|
with:
|
26
|
-
ruby-version:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
27
25
|
|
28
26
|
- name: Install dependencies
|
29
27
|
run: bundle install
|
data/.rubocop.yml
CHANGED
@@ -27,20 +27,6 @@ Metrics/ParameterLists:
|
|
27
27
|
|
28
28
|
Metrics/LineLength:
|
29
29
|
Max: 135
|
30
|
-
Exclude:
|
31
|
-
- spec/sse/**/*
|
32
|
-
- spec/integrations/**/*
|
33
|
-
- spec/engine/sync_manager_spec.rb
|
34
|
-
- spec/engine/auth_api_client_spec.rb
|
35
|
-
- spec/telemetry/synchronizer_spec.rb
|
36
|
-
- spec/splitclient/split_config_spec.rb
|
37
|
-
- spec/engine/push_manager_spec.rb
|
38
|
-
- spec/cache/senders/impressions_sender_adapter_spec.rb
|
39
|
-
|
40
|
-
Style/BracesAroundHashParameters:
|
41
|
-
Exclude:
|
42
|
-
- spec/integrations/push_client_spec.rb
|
43
|
-
- spec/engine/synchronizer_spec.rb
|
44
30
|
|
45
31
|
Metrics/BlockLength:
|
46
32
|
Exclude:
|
@@ -51,8 +37,24 @@ Naming/FileName:
|
|
51
37
|
Exclude:
|
52
38
|
- splitclient-rb.gemspec
|
53
39
|
|
40
|
+
Style/OptionalBooleanParameter:
|
41
|
+
Exclude:
|
42
|
+
- lib/splitclient-rb/engine/matchers/between_matcher.rb
|
43
|
+
- lib/splitclient-rb/engine/matchers/combining_matcher.rb
|
44
|
+
- lib/splitclient-rb/engine/matchers/equal_to_matcher.rb
|
45
|
+
- lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb
|
46
|
+
- lib/splitclient-rb/engine/matchers/greater_than_or_equal_to_matcher.rb
|
47
|
+
|
48
|
+
Style/HashTransformKeys:
|
49
|
+
Exclude:
|
50
|
+
- lib/splitclient-rb/engine/matchers/combining_matcher.rb
|
51
|
+
|
52
|
+
Style/RedundantReturn:
|
53
|
+
Exclude:
|
54
|
+
- lib/splitclient-rb/engine/common/impressions_manager.rb
|
55
|
+
|
54
56
|
AllCops:
|
55
|
-
TargetRubyVersion: 2.
|
57
|
+
TargetRubyVersion: 2.5
|
56
58
|
Exclude:
|
57
59
|
- gemfiles/* # excluded as appraisal generates them with errors
|
58
60
|
- lib/*
|
@@ -70,3 +72,5 @@ AllCops:
|
|
70
72
|
- lib/splitclient-rb/engine/synchronizer.rb
|
71
73
|
- tmp/**/*
|
72
74
|
- lib/splitclient-rb/sse/event_source/client.rb
|
75
|
+
- spec/**/*
|
76
|
+
- .simplecov
|
data/CHANGES.txt
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
CHANGES
|
2
2
|
|
3
|
+
8.0.0 (May 10, 2022)
|
4
|
+
- BREAKING CHANGE: Deprecated support for ruby 2.3 and 2.4 versions. The minimum ruby version required is 2.5 now.
|
5
|
+
- Updated redis command for config telemetry, using hset instead of rpush now.
|
6
|
+
- Updated dependencies:
|
7
|
+
- rake to ~> 13.0
|
8
|
+
- faraday to >= 1.1, < 2.0
|
9
|
+
|
3
10
|
7.3.4 (Feb 21, 2022)
|
4
11
|
- Updated streaming events architecture with a new queue logic.
|
5
12
|
- Fixed redis integration Pipelining command deprecation warning.
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Split SDK for Ruby
|
2
|
-
|
2
|
+
![Build Status](https://github.com/splitio/ruby-client/actions/workflows/ci.yml/badge.svg?branch=master)
|
3
3
|
|
4
4
|
## Overview
|
5
5
|
This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience.
|
@@ -7,7 +7,7 @@ This SDK is designed to work with Split, the platform for controlled rollouts, w
|
|
7
7
|
[![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)
|
8
8
|
|
9
9
|
## Compatibility
|
10
|
-
The Ruby SDK support Ruby version 2.
|
10
|
+
The Ruby SDK support Ruby version 2.5.0 or later and JRuby or 9.1.17 o later.
|
11
11
|
|
12
12
|
Also the Ruby SDK has been tested as a standalone app as well as using the following web servers:
|
13
13
|
- Puma
|
data/Rakefile
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
require 'rubocop/rake_task'
|
6
|
-
require 'appraisal'
|
7
6
|
|
8
7
|
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
9
8
|
|
@@ -26,10 +25,4 @@ else
|
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
|
-
task :default do
|
31
|
-
sh 'appraisal install && rake appraisal && rake rubocop'
|
32
|
-
end
|
33
|
-
else
|
34
|
-
task default: %i[spec rubocop]
|
35
|
-
end
|
28
|
+
task default: %i[spec rubocop]
|
@@ -30,16 +30,16 @@ module SplitIoClient
|
|
30
30
|
fetch_segment(name, fetch_options) if change_number == -1
|
31
31
|
end
|
32
32
|
end
|
33
|
-
rescue StandardError =>
|
34
|
-
@config.log_found_exception(__method__.to_s,
|
33
|
+
rescue StandardError => e
|
34
|
+
@config.log_found_exception(__method__.to_s, e)
|
35
35
|
end
|
36
36
|
|
37
37
|
def fetch_segment(name, fetch_options = { cache_control_headers: false, till: nil })
|
38
38
|
@semaphore.synchronize do
|
39
39
|
segments_api.fetch_segments_by_names([name], fetch_options)
|
40
40
|
end
|
41
|
-
rescue StandardError =>
|
42
|
-
@config.log_found_exception(__method__.to_s,
|
41
|
+
rescue StandardError => e
|
42
|
+
@config.log_found_exception(__method__.to_s, e)
|
43
43
|
end
|
44
44
|
|
45
45
|
def fetch_segments
|
@@ -48,8 +48,8 @@ module SplitIoClient
|
|
48
48
|
|
49
49
|
true
|
50
50
|
end
|
51
|
-
rescue StandardError =>
|
52
|
-
@config.log_found_exception(__method__.to_s,
|
51
|
+
rescue StandardError => e
|
52
|
+
@config.log_found_exception(__method__.to_s, e)
|
53
53
|
false
|
54
54
|
end
|
55
55
|
|
@@ -36,8 +36,8 @@ module SplitIoClient
|
|
36
36
|
|
37
37
|
{ segment_names: data[:segment_names], success: true }
|
38
38
|
end
|
39
|
-
rescue StandardError =>
|
40
|
-
@config.log_found_exception(__method__.to_s,
|
39
|
+
rescue StandardError => e
|
40
|
+
@config.log_found_exception(__method__.to_s, e)
|
41
41
|
{ segment_names: [], success: false }
|
42
42
|
end
|
43
43
|
|
@@ -19,8 +19,8 @@ module SplitIoClient
|
|
19
19
|
post_events if @size >= EVENTS_MAX_SIZE_BYTES || @adapter.length == @config.events_queue_size
|
20
20
|
|
21
21
|
@telemetry_runtime_producer.record_events_stats(Telemetry::Domain::Constants::EVENTS_QUEUED, 1)
|
22
|
-
rescue StandardError =>
|
23
|
-
@config.log_found_exception(__method__.to_s,
|
22
|
+
rescue StandardError => e
|
23
|
+
@config.log_found_exception(__method__.to_s, e)
|
24
24
|
@telemetry_runtime_producer.record_events_stats(Telemetry::Domain::Constants::EVENTS_DROPPED, 1)
|
25
25
|
end
|
26
26
|
|
@@ -21,8 +21,8 @@ module SplitIoClient
|
|
21
21
|
|
22
22
|
def post_events
|
23
23
|
events_api.post(self.clear)
|
24
|
-
rescue StandardError =>
|
25
|
-
@config.log_found_exception(__method__.to_s,
|
24
|
+
rescue StandardError => e
|
25
|
+
@config.log_found_exception(__method__.to_s, e)
|
26
26
|
end
|
27
27
|
|
28
28
|
protected
|
@@ -41,8 +41,8 @@ module SplitIoClient
|
|
41
41
|
attributes: impression[:attributes]
|
42
42
|
}
|
43
43
|
@queue.push(imp) if @listener
|
44
|
-
rescue StandardError =>
|
45
|
-
@config.log_found_exception(__method__.to_s,
|
44
|
+
rescue StandardError => e
|
45
|
+
@config.log_found_exception(__method__.to_s, e)
|
46
46
|
end
|
47
47
|
|
48
48
|
def router_thread
|
@@ -50,8 +50,8 @@ module SplitIoClient
|
|
50
50
|
loop do
|
51
51
|
begin
|
52
52
|
@listener.log(@queue.pop)
|
53
|
-
rescue StandardError =>
|
54
|
-
@config.log_found_exception(__method__.to_s,
|
53
|
+
rescue StandardError => e
|
54
|
+
@config.log_found_exception(__method__.to_s, e)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -31,17 +31,17 @@ module SplitIoClient
|
|
31
31
|
def uniques_formatter(uniques)
|
32
32
|
return if uniques.nil? || uniques.empty?
|
33
33
|
|
34
|
-
to_return = {
|
34
|
+
to_return = { keys: [] }
|
35
35
|
uniques.each do |key, value|
|
36
|
-
to_return[:
|
36
|
+
to_return[:keys] << {
|
37
37
|
f: key,
|
38
38
|
ks: value.to_a
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
42
|
to_return
|
43
|
-
rescue StandardError =>
|
44
|
-
@config.log_found_exception(__method__.to_s,
|
43
|
+
rescue StandardError => e
|
44
|
+
@config.log_found_exception(__method__.to_s, e)
|
45
45
|
nil
|
46
46
|
end
|
47
47
|
|
@@ -61,8 +61,8 @@ module SplitIoClient
|
|
61
61
|
end
|
62
62
|
|
63
63
|
formated_counts
|
64
|
-
rescue StandardError =>
|
65
|
-
@config.log_found_exception(__method__.to_s,
|
64
|
+
rescue StandardError => e
|
65
|
+
@config.log_found_exception(__method__.to_s, e)
|
66
66
|
nil
|
67
67
|
end
|
68
68
|
end
|
@@ -29,8 +29,6 @@ module SplitIoClient
|
|
29
29
|
impressions_count.each do |key, value|
|
30
30
|
pipeline.hincrby(impressions_count_key, key, value)
|
31
31
|
end
|
32
|
-
|
33
|
-
@future = pipeline.hlen(impressions_count_key)
|
34
32
|
end
|
35
33
|
|
36
34
|
expire_impressions_count_key(impressions_count, result)
|
@@ -67,8 +65,8 @@ module SplitIoClient
|
|
67
65
|
end
|
68
66
|
|
69
67
|
to_return
|
70
|
-
rescue StandardError =>
|
71
|
-
@config.log_found_exception(__method__.to_s,
|
68
|
+
rescue StandardError => e
|
69
|
+
@config.log_found_exception(__method__.to_s, e)
|
72
70
|
nil
|
73
71
|
end
|
74
72
|
end
|
@@ -24,7 +24,7 @@ module SplitIoClient
|
|
24
24
|
sleep(@config.counter_refresh_rate)
|
25
25
|
post_impressions_count
|
26
26
|
end
|
27
|
-
rescue SplitIoClient::SDKShutdownException
|
27
|
+
rescue SplitIoClient::SDKShutdownException
|
28
28
|
post_impressions_count
|
29
29
|
|
30
30
|
@config.logger.info('Posting impressions count due to shutdown')
|
@@ -34,8 +34,8 @@ module SplitIoClient
|
|
34
34
|
|
35
35
|
def post_impressions_count
|
36
36
|
@impressions_sender_adapter.record_impressions_count(@impression_counter.pop_all)
|
37
|
-
rescue StandardError =>
|
38
|
-
@config.log_found_exception(__method__.to_s,
|
37
|
+
rescue StandardError => e
|
38
|
+
@config.log_found_exception(__method__.to_s, e)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -39,8 +39,8 @@ module SplitIoClient
|
|
39
39
|
.call(fetch_all_impressions)
|
40
40
|
|
41
41
|
impressions_api.post(formatted_impressions)
|
42
|
-
rescue StandardError =>
|
43
|
-
@config.log_found_exception(__method__.to_s,
|
42
|
+
rescue StandardError => e
|
43
|
+
@config.log_found_exception(__method__.to_s, e)
|
44
44
|
end
|
45
45
|
|
46
46
|
def impressions_api
|
@@ -46,10 +46,10 @@ module SplitIoClient
|
|
46
46
|
end
|
47
47
|
|
48
48
|
@status_manager.ready! if @status_manager
|
49
|
-
rescue StandardError =>
|
49
|
+
rescue StandardError => e
|
50
50
|
@config.logger.error('Error while parsing the split file. ' \
|
51
51
|
'Check that the input file matches the expected format')
|
52
|
-
@config.log_found_exception(__method__.to_s,
|
52
|
+
@config.log_found_exception(__method__.to_s, e)
|
53
53
|
end
|
54
54
|
|
55
55
|
def store_split(split)
|
@@ -110,8 +110,8 @@ module SplitIoClient
|
|
110
110
|
@events_repository.add(key.to_s, traffic_type_name.downcase, event_type.to_s, (Time.now.to_f * 1000).to_i, value, properties, properties_size)
|
111
111
|
record_latency(TRACK, start)
|
112
112
|
true
|
113
|
-
rescue StandardError =>
|
114
|
-
@config.log_found_exception(__method__.to_s,
|
113
|
+
rescue StandardError => e
|
114
|
+
@config.log_found_exception(__method__.to_s, e)
|
115
115
|
record_exception(TRACK)
|
116
116
|
|
117
117
|
false
|
@@ -291,8 +291,8 @@ module SplitIoClient
|
|
291
291
|
|
292
292
|
impression = @impressions_manager.build_impression(matching_key, bucketing_key, split_name, treatment_data, { attributes: attributes, time: nil })
|
293
293
|
impressions << impression unless impression.nil?
|
294
|
-
rescue StandardError =>
|
295
|
-
@config.log_found_exception(__method__.to_s,
|
294
|
+
rescue StandardError => e
|
295
|
+
@config.log_found_exception(__method__.to_s, e)
|
296
296
|
|
297
297
|
record_exception(calling_method)
|
298
298
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'net/http/persistent'
|
4
|
-
|
5
3
|
module SplitIoClient
|
6
4
|
module Api
|
7
5
|
class Client
|
@@ -54,33 +52,12 @@ module SplitIoClient
|
|
54
52
|
private
|
55
53
|
|
56
54
|
def api_client
|
57
|
-
if needs_patched_net_http_persistent_adapter?
|
58
|
-
require 'splitclient-rb/engine/api/faraday_adapter/patched_net_http_persistent'
|
59
|
-
|
60
|
-
Faraday::Adapter.register_middleware(
|
61
|
-
net_http_persistent: SplitIoClient::FaradayAdapter::PatchedNetHttpPersistent
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
55
|
@api_client ||= Faraday.new do |builder|
|
66
56
|
builder.use SplitIoClient::FaradayMiddleware::Gzip
|
67
57
|
builder.adapter :net_http_persistent
|
68
58
|
end
|
69
59
|
end
|
70
60
|
|
71
|
-
def needs_patched_net_http_persistent_adapter?
|
72
|
-
new_net_http_persistent? && incompatible_faraday_version?
|
73
|
-
end
|
74
|
-
|
75
|
-
def incompatible_faraday_version?
|
76
|
-
version = Faraday::VERSION.split('.')[0..1]
|
77
|
-
version[0].to_i == 0 && version[1].to_i < 13
|
78
|
-
end
|
79
|
-
|
80
|
-
def new_net_http_persistent?
|
81
|
-
Net::HTTP::Persistent::VERSION.split('.').first.to_i >= 3
|
82
|
-
end
|
83
|
-
|
84
61
|
def common_headers(api_key)
|
85
62
|
{
|
86
63
|
'Authorization' => "Bearer #{api_key}",
|
@@ -18,9 +18,9 @@ module SplitIoClient
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def record_unique_keys(uniques)
|
21
|
-
return if uniques[:
|
21
|
+
return if uniques[:keys].empty?
|
22
22
|
|
23
|
-
post_telemetry("#{@config.telemetry_service_url}/
|
23
|
+
post_telemetry("#{@config.telemetry_service_url}/keys/ss", uniques, 'unique_keys')
|
24
24
|
rescue StandardError => e
|
25
25
|
@config.log_found_exception(__method__.to_s, e)
|
26
26
|
end
|
@@ -85,8 +85,8 @@ module SplitIoClient
|
|
85
85
|
control_pri = SplitIoClient::Constants::CONTROL_PRI
|
86
86
|
control_sec = SplitIoClient::Constants::CONTROL_SEC
|
87
87
|
channels_string = channels_string.gsub(control_pri, "#{prefix}#{control_pri}")
|
88
|
-
|
89
|
-
channels_string
|
88
|
+
|
89
|
+
channels_string.gsub(control_sec, "#{prefix}#{control_sec}")
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
@@ -9,15 +9,13 @@ module SplitIoClient
|
|
9
9
|
impression_counter,
|
10
10
|
telemetry_runtime_producer,
|
11
11
|
impression_observer,
|
12
|
-
unique_keys_tracker
|
13
|
-
impression_router)
|
12
|
+
unique_keys_tracker)
|
14
13
|
@config = config
|
15
14
|
@impressions_repository = impressions_repository
|
16
15
|
@impression_counter = impression_counter
|
17
16
|
@impression_observer = impression_observer
|
18
17
|
@telemetry_runtime_producer = telemetry_runtime_producer
|
19
18
|
@unique_keys_tracker = unique_keys_tracker
|
20
|
-
@impression_router = impression_router
|
21
19
|
end
|
22
20
|
|
23
21
|
def build_impression(matching_key, bucketing_key, split_name, treatment, params = {})
|
@@ -58,12 +56,18 @@ module SplitIoClient
|
|
58
56
|
@config.log_found_exception(__method__.to_s, e)
|
59
57
|
ensure
|
60
58
|
record_stats(stats)
|
61
|
-
|
59
|
+
impression_router.add_bulk(impressions)
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
65
63
|
private
|
66
64
|
|
65
|
+
def impression_router
|
66
|
+
@impression_router ||= SplitIoClient::ImpressionRouter.new(@config)
|
67
|
+
rescue StandardError => e
|
68
|
+
@config.log_found_exception(__method__.to_s, e)
|
69
|
+
end
|
70
|
+
|
67
71
|
def record_stats(stats)
|
68
72
|
return if redis?
|
69
73
|
|
@@ -6,10 +6,6 @@ module SplitIoClient
|
|
6
6
|
|
7
7
|
attr_reader :attribute
|
8
8
|
|
9
|
-
def initialize(attribute, remote_array, logger)
|
10
|
-
super(attribute, remote_array, logger)
|
11
|
-
end
|
12
|
-
|
13
9
|
def match?(args)
|
14
10
|
if @remote_set.empty?
|
15
11
|
@logger.log_if_debug('[ContainsAllMatcher] Remote Set Empty')
|
@@ -6,10 +6,6 @@ module SplitIoClient
|
|
6
6
|
|
7
7
|
attr_reader :attribute
|
8
8
|
|
9
|
-
def initialize(attribute, remote_array, logger)
|
10
|
-
super(attribute, remote_array, logger)
|
11
|
-
end
|
12
|
-
|
13
9
|
def match?(args)
|
14
10
|
matches = local_set(args[:attributes], @attribute).intersect? @remote_set
|
15
11
|
@logger.log_if_debug("[ContainsAnyMatcher] Remote Set #{@remote_set} contains any \
|
@@ -41,17 +41,20 @@ module SplitIoClient
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def schedule_next_token_refresh(time)
|
44
|
-
@config.threads[:schedule_next_token_refresh] = Thread.new
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
44
|
+
@config.threads[:schedule_next_token_refresh] = Thread.new { refresh_token_task(time) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def refresh_token_task(time)
|
48
|
+
@config.logger.debug("schedule_next_token_refresh refresh in #{time} seconds.") if @config.debug_enabled
|
49
|
+
|
50
|
+
sleep(time)
|
51
|
+
|
52
|
+
@config.logger.debug('schedule_next_token_refresh starting ...') if @config.debug_enabled
|
53
|
+
@sse_handler.stop
|
54
|
+
|
55
|
+
start_sse
|
56
|
+
rescue StandardError => e
|
57
|
+
@config.logger.debug("schedule_next_token_refresh error: #{e.inspect}") if @config.debug_enabled
|
55
58
|
end
|
56
59
|
|
57
60
|
def record_telemetry(time)
|
@@ -96,8 +96,8 @@ module SplitIoClient
|
|
96
96
|
else
|
97
97
|
@config.logger.debug("No changes fetched after #{attempts} attempts with CDN bypassed.") if @config.debug_enabled
|
98
98
|
end
|
99
|
-
rescue StandardError =>
|
100
|
-
@config.log_found_exception(__method__.to_s,
|
99
|
+
rescue StandardError => e
|
100
|
+
@config.log_found_exception(__method__.to_s, e)
|
101
101
|
end
|
102
102
|
|
103
103
|
def fetch_segment(name, target_change_number)
|
@@ -132,8 +132,8 @@ module SplitIoClient
|
|
132
132
|
else
|
133
133
|
@config.logger.debug("No changes fetched for segment #{name} after #{attempts} attempts with CDN bypassed.") if @config.debug_enabled
|
134
134
|
end
|
135
|
-
rescue StandardError =>
|
136
|
-
@config.log_found_exception(__method__.to_s,
|
135
|
+
rescue StandardError => e
|
136
|
+
@config.log_found_exception(__method__.to_s, e)
|
137
137
|
end
|
138
138
|
|
139
139
|
private
|
@@ -51,7 +51,7 @@ module SplitIoClient
|
|
51
51
|
|
52
52
|
@segments_refresh_rate = opts[:segments_refresh_rate] || SplitConfig.default_segments_refresh_rate
|
53
53
|
|
54
|
-
@impressions_mode = init_impressions_mode(opts[:impressions_mode])
|
54
|
+
@impressions_mode = init_impressions_mode(opts[:impressions_mode], opts[:cache_adapter])
|
55
55
|
|
56
56
|
@impressions_refresh_rate = SplitConfig.init_impressions_refresh_rate(@impressions_mode, opts[:impressions_refresh_rate], SplitConfig.default_impressions_refresh_rate)
|
57
57
|
@impressions_queue_size = opts[:impressions_queue_size] || SplitConfig.default_impressions_queue_size
|
@@ -314,14 +314,16 @@ module SplitIoClient
|
|
314
314
|
:optimized
|
315
315
|
end
|
316
316
|
|
317
|
-
def init_impressions_mode(impressions_mode)
|
317
|
+
def init_impressions_mode(impressions_mode, adapter)
|
318
318
|
impressions_mode ||= SplitConfig.default_impressions_mode
|
319
319
|
|
320
|
+
return :debug if adapter == :redis
|
321
|
+
|
320
322
|
case impressions_mode
|
321
323
|
when :debug
|
322
324
|
return :debug
|
323
|
-
when :none
|
324
|
-
|
325
|
+
# when :none // we not support :none impression mode yet. Defaulting to :optimized mode
|
326
|
+
# return :none
|
325
327
|
else
|
326
328
|
@logger.error('You passed an invalid impressions_mode, impressions_mode should be one of the following values: :debug or :optimized. Defaulting to :optimized mode') unless impressions_mode == :optimized
|
327
329
|
return :optimized
|
@@ -65,7 +65,7 @@ module SplitIoClient
|
|
65
65
|
build_streaming_components
|
66
66
|
build_sync_manager
|
67
67
|
|
68
|
-
@sync_manager.start
|
68
|
+
@sync_manager.start
|
69
69
|
end
|
70
70
|
|
71
71
|
def stop!
|
@@ -127,10 +127,10 @@ module SplitIoClient
|
|
127
127
|
def validate_api_key
|
128
128
|
if(@api_key.nil?)
|
129
129
|
@config.logger.error('Factory Instantiation: you passed a nil api_key, api_key must be a non-empty String')
|
130
|
-
@config.valid_mode =
|
130
|
+
@config.valid_mode = false
|
131
131
|
elsif (@api_key.empty?)
|
132
132
|
@config.logger.error('Factory Instantiation: you passed and empty api_key, api_key must be a non-empty String')
|
133
|
-
@config.valid_mode =
|
133
|
+
@config.valid_mode = false
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
@@ -249,8 +249,7 @@ module SplitIoClient
|
|
249
249
|
build_impressions_observer
|
250
250
|
build_impression_counter
|
251
251
|
|
252
|
-
|
253
|
-
@impressions_manager = Engine::Common::ImpressionManager.new(@config, @impressions_repository, @impression_counter, @runtime_producer, @impression_observer, @unique_keys_tracker, impression_router)
|
252
|
+
@impressions_manager = Engine::Common::ImpressionManager.new(@config, @impressions_repository, @impression_counter, @runtime_producer, @impression_observer, @unique_keys_tracker)
|
254
253
|
end
|
255
254
|
end
|
256
255
|
end
|