splitclient-rb 7.3.5.pre.rc5 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +7 -9
  3. data/.rubocop.yml +19 -15
  4. data/CHANGES.txt +7 -0
  5. data/README.md +2 -2
  6. data/Rakefile +1 -8
  7. data/lib/splitclient-rb/cache/fetchers/segment_fetcher.rb +6 -6
  8. data/lib/splitclient-rb/cache/fetchers/split_fetcher.rb +2 -2
  9. data/lib/splitclient-rb/cache/repositories/events/memory_repository.rb +2 -2
  10. data/lib/splitclient-rb/cache/repositories/events_repository.rb +2 -2
  11. data/lib/splitclient-rb/cache/repositories/segments_repository.rb +2 -2
  12. data/lib/splitclient-rb/cache/routers/impression_router.rb +4 -4
  13. data/lib/splitclient-rb/cache/senders/impressions_adapter/memory_sender.rb +6 -6
  14. data/lib/splitclient-rb/cache/senders/impressions_adapter/redis_sender.rb +2 -4
  15. data/lib/splitclient-rb/cache/senders/impressions_count_sender.rb +2 -2
  16. data/lib/splitclient-rb/cache/senders/impressions_sender.rb +2 -2
  17. data/lib/splitclient-rb/cache/stores/localhost_split_store.rb +2 -2
  18. data/lib/splitclient-rb/clients/split_client.rb +4 -4
  19. data/lib/splitclient-rb/engine/api/client.rb +0 -23
  20. data/lib/splitclient-rb/engine/api/telemetry_api.rb +2 -2
  21. data/lib/splitclient-rb/engine/auth_api_client.rb +2 -2
  22. data/lib/splitclient-rb/engine/common/impressions_manager.rb +2 -2
  23. data/lib/splitclient-rb/engine/matchers/contains_all_matcher.rb +0 -4
  24. data/lib/splitclient-rb/engine/matchers/contains_any_matcher.rb +0 -4
  25. data/lib/splitclient-rb/engine/matchers/equal_to_set_matcher.rb +0 -4
  26. data/lib/splitclient-rb/engine/matchers/part_of_set_matcher.rb +0 -4
  27. data/lib/splitclient-rb/engine/push_manager.rb +14 -11
  28. data/lib/splitclient-rb/engine/synchronizer.rb +4 -4
  29. data/lib/splitclient-rb/sse/notification_manager_keeper.rb +3 -2
  30. data/lib/splitclient-rb/telemetry/memory/memory_evaluation_consumer.rb +1 -1
  31. data/lib/splitclient-rb/telemetry/memory/memory_evaluation_producer.rb +5 -5
  32. data/lib/splitclient-rb/telemetry/memory/memory_init_consumer.rb +1 -1
  33. data/lib/splitclient-rb/telemetry/memory/memory_init_producer.rb +5 -5
  34. data/lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb +1 -1
  35. data/lib/splitclient-rb/telemetry/memory/memory_runtime_producer.rb +20 -20
  36. data/lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb +5 -5
  37. data/lib/splitclient-rb/telemetry/redis/redis_evaluation_producer.rb +1 -1
  38. data/lib/splitclient-rb/telemetry/redis/redis_init_producer.rb +2 -2
  39. data/lib/splitclient-rb/telemetry/redis/redis_synchronizer.rb +3 -3
  40. data/lib/splitclient-rb/telemetry/sync_task.rb +11 -11
  41. data/lib/splitclient-rb/version.rb +1 -1
  42. data/lib/splitclient-rb.rb +0 -1
  43. data/splitclient-rb.gemspec +4 -6
  44. metadata +11 -27
  45. data/Appraisals +0 -10
  46. 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
  SHA256:
3
- metadata.gz: '08a6682acfcd86d8f14ad73419ba14c363fdab486f74fed00ab2600102933a92'
4
- data.tar.gz: 38263b8206e23447673e3008418bb7a4ce127ba14f8d861d748946979584f1e7
3
+ metadata.gz: 065f81ab73e55065b4386880e8393f0ad262c4cd4b930639050f8ee1a38005f5
4
+ data.tar.gz: 10ec816d48bf218ce0ef61224b0ab6f9eaa1bb5b1542a7d0dffb39fcad16da84
5
5
  SHA512:
6
- metadata.gz: 6ca8ca135cced312d33d7cd66d29e17c0177ce2c57b34a2c89c9b453abcde26894572ec040584890d8a7af1033629188a802a4df8c721f666ce4a5efbefaa993
7
- data.tar.gz: bbc878936be9b1e91ea205ee13c25861d74a2cfb2e2b6d1f7d188d0f2a07609e8987dc009e9bc6869914ea667da6198f32742a5d42ded2a075e5e8b169ac119b
6
+ metadata.gz: 4c5c6314899dd965baa6a5994c0e0054521cbe502ac224f70712a655a001ec753ae41328a34cc132365e524d5833eb1735c31cb32e1685b51cabbbf6088ad428
7
+ data.tar.gz: cae9ebe522db54858c44af56d58e55eefbce80513aae24801c2d4a5974bb0c9482ee8d8be0fb2b9807967887d8b8e3d7bfb12bc73ef9b08e9c0b0c0a33854e77
@@ -1,10 +1,4 @@
1
- on:
2
- push:
3
- branches:
4
- - do-not-send-impressions
5
- pull_request:
6
- branches:
7
- - do-not-send-impressions
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
21
+ - name: Set up Ruby ${{ matrix.ruby }}
24
22
  uses: ruby/setup-ruby@v1
25
23
  with:
26
- ruby-version: 2.5
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.3.6
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
- [![Build Status](https://travis-ci.com/splitio/ruby-client.svg?branch=master)](https://travis-ci.com/splitio/ruby-client)
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.3.0 or later and JRuby or 9.1.17 o later.
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
- if !ENV['APPRAISAL_INITIALIZED']
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 => error
34
- @config.log_found_exception(__method__.to_s, error)
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 => error
42
- @config.log_found_exception(__method__.to_s, error)
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 => error
52
- @config.log_found_exception(__method__.to_s, error)
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 => error
40
- @config.log_found_exception(__method__.to_s, error)
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 => error
23
- @config.log_found_exception(__method__.to_s, error)
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 => error
25
- @config.log_found_exception(__method__.to_s, error)
24
+ rescue StandardError => e
25
+ @config.log_found_exception(__method__.to_s, e)
26
26
  end
27
27
 
28
28
  protected
@@ -78,8 +78,8 @@ module SplitIoClient
78
78
  end
79
79
 
80
80
  keys
81
- rescue StandardError => error
82
- @config.log_found_exception(__method__.to_s, error)
81
+ rescue StandardError => e
82
+ @config.log_found_exception(__method__.to_s, e)
83
83
  0
84
84
  end
85
85
 
@@ -41,8 +41,8 @@ module SplitIoClient
41
41
  attributes: impression[:attributes]
42
42
  }
43
43
  @queue.push(imp) if @listener
44
- rescue StandardError => error
45
- @config.log_found_exception(__method__.to_s, error)
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 => error
54
- @config.log_found_exception(__method__.to_s, error)
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 = { mtks: [] }
34
+ to_return = { keys: [] }
35
35
  uniques.each do |key, value|
36
- to_return[:mtks] << {
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 => error
44
- @config.log_found_exception(__method__.to_s, error)
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 => error
65
- @config.log_found_exception(__method__.to_s, error)
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 => error
71
- @config.log_found_exception(__method__.to_s, error)
68
+ rescue StandardError => e
69
+ @config.log_found_exception(__method__.to_s, e)
72
70
  nil
73
71
  end
74
72
  end
@@ -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 => error
38
- @config.log_found_exception(__method__.to_s, error)
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 => error
43
- @config.log_found_exception(__method__.to_s, error)
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 => error
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, error)
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 => error
114
- @config.log_found_exception(__method__.to_s, error)
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 => error
295
- @config.log_found_exception(__method__.to_s, error)
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[:mtks].empty?
21
+ return if uniques[:keys].empty?
22
22
 
23
- post_telemetry("#{@config.telemetry_service_url}/mtks/ss", uniques, 'mtks')
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
- channels_string = channels_string.gsub(control_sec, "#{prefix}#{control_sec}")
89
- channels_string
88
+
89
+ channels_string.gsub(control_sec, "#{prefix}#{control_sec}")
90
90
  end
91
91
  end
92
92
  end
@@ -64,8 +64,8 @@ module SplitIoClient
64
64
 
65
65
  def impression_router
66
66
  @impression_router ||= SplitIoClient::ImpressionRouter.new(@config)
67
- rescue StandardError => error
68
- @config.log_found_exception(__method__.to_s, error)
67
+ rescue StandardError => e
68
+ @config.log_found_exception(__method__.to_s, e)
69
69
  end
70
70
 
71
71
  def record_stats(stats)
@@ -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 \
@@ -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
  set = local_set(args[:attributes], @attribute)
15
11
  matches = set == @remote_set
@@ -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
  @local_set = local_set(args[:attributes], @attribute)
15
11
 
@@ -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 do
45
- begin
46
- @config.logger.debug("schedule_next_token_refresh refresh in #{time} seconds.") if @config.debug_enabled
47
- sleep(time)
48
- @config.logger.debug('schedule_next_token_refresh starting ...') if @config.debug_enabled
49
- @sse_handler.stop
50
- start_sse
51
- rescue StandardError => e
52
- @config.logger.debug("schedule_next_token_refresh error: #{e.inspect}") if @config.debug_enabled
53
- end
54
- end
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 => error
100
- @config.log_found_exception(__method__.to_s, error)
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 => error
136
- @config.log_found_exception(__method__.to_s, error)
135
+ rescue StandardError => e
136
+ @config.log_found_exception(__method__.to_s, e)
137
137
  end
138
138
 
139
139
  private
@@ -61,10 +61,11 @@ module SplitIoClient
61
61
  end
62
62
 
63
63
  def update_publishers(channel, publishers)
64
- if channel == Constants::CONTROL_PRI
64
+ case channel
65
+ when Constants::CONTROL_PRI
65
66
  @telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::OCCUPANCY_PRI, publishers)
66
67
  @publishers_pri.value = publishers
67
- elsif channel == Constants::CONTROL_SEC
68
+ when Constants::CONTROL_SEC
68
69
  @telemetry_runtime_producer.record_streaming_event(Telemetry::Domain::Constants::OCCUPANCY_SEC, publishers)
69
70
  @publishers_sec.value = publishers
70
71
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class MemoryEvaluationConsumer < EvaluationConsumer
5
+ class MemoryEvaluationConsumer
6
6
  def initialize(config)
7
7
  @config = config
8
8
  @adapter = config.telemetry_adapter
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class MemoryEvaluationProducer < EvaluationProducer
5
+ class MemoryEvaluationProducer
6
6
  def initialize(config)
7
7
  @config = config
8
8
  @adapter = config.telemetry_adapter
@@ -10,14 +10,14 @@ module SplitIoClient
10
10
 
11
11
  def record_latency(method, bucket)
12
12
  @adapter.latencies.find { |l| l[:method] == method }[:latencies][bucket] += 1
13
- rescue StandardError => error
14
- @config.log_found_exception(__method__.to_s, error)
13
+ rescue StandardError => e
14
+ @config.log_found_exception(__method__.to_s, e)
15
15
  end
16
16
 
17
17
  def record_exception(method)
18
18
  @adapter.exceptions.find { |l| l[:method] == method }[:exceptions].increment
19
- rescue StandardError => error
20
- @config.log_found_exception(__method__.to_s, error)
19
+ rescue StandardError => e
20
+ @config.log_found_exception(__method__.to_s, e)
21
21
  end
22
22
  end
23
23
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class MemoryInitConsumer < InitConsumer
5
+ class MemoryInitConsumer
6
6
  DEFAULT_VALUE = 0
7
7
 
8
8
  def initialize(config)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class MemoryInitProducer < InitProducer
5
+ class MemoryInitProducer
6
6
  def initialize(config)
7
7
  @config = config
8
8
  @adapter = config.telemetry_adapter
@@ -14,14 +14,14 @@ module SplitIoClient
14
14
 
15
15
  def record_bur_timeout
16
16
  find_factory_counters(Domain::Constants::BUR_TIMEOUT)[:counts].increment
17
- rescue StandardError => error
18
- @config.log_found_exception(__method__.to_s, error)
17
+ rescue StandardError => e
18
+ @config.log_found_exception(__method__.to_s, e)
19
19
  end
20
20
 
21
21
  def record_non_ready_usages
22
22
  find_factory_counters(Domain::Constants::NON_READY_USAGES)[:counts].increment
23
- rescue StandardError => error
24
- @config.log_found_exception(__method__.to_s, error)
23
+ rescue StandardError => e
24
+ @config.log_found_exception(__method__.to_s, e)
25
25
  end
26
26
 
27
27
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class MemoryRuntimeConsumer < RuntimeConsumer
5
+ class MemoryRuntimeConsumer
6
6
  DEFAULT_VALUE = 0
7
7
 
8
8
  def initialize(config)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class MemoryRuntimeProducer < RuntimeProducer
5
+ class MemoryRuntimeProducer
6
6
  def initialize(config)
7
7
  @config = config
8
8
  @adapter = config.telemetry_adapter
@@ -16,22 +16,22 @@ module SplitIoClient
16
16
 
17
17
  def record_impressions_stats(type, count)
18
18
  @adapter.impressions_data_records.find { |l| l[:type] == type }[:value].value += count unless count.zero?
19
- rescue StandardError => error
20
- @config.log_found_exception(__method__.to_s, error)
19
+ rescue StandardError => e
20
+ @config.log_found_exception(__method__.to_s, e)
21
21
  end
22
22
 
23
23
  def record_events_stats(type, count)
24
24
  @adapter.events_data_records.find { |l| l[:type] == type }[:value].value += count unless count.zero?
25
- rescue StandardError => error
26
- @config.log_found_exception(__method__.to_s, error)
25
+ rescue StandardError => e
26
+ @config.log_found_exception(__method__.to_s, e)
27
27
  end
28
28
 
29
29
  def record_successful_sync(type, value = nil)
30
30
  value = (Time.now.to_f * 1000.0).to_i if value.nil?
31
31
 
32
32
  @adapter.last_synchronization.find { |l| l[:type] == type }[:value] = Concurrent::AtomicFixnum.new(value)
33
- rescue StandardError => error
34
- @config.log_found_exception(__method__.to_s, error)
33
+ rescue StandardError => e
34
+ @config.log_found_exception(__method__.to_s, e)
35
35
  end
36
36
 
37
37
  def record_sync_error(type, status)
@@ -39,42 +39,42 @@ module SplitIoClient
39
39
 
40
40
  begin
41
41
  http_errors[status] += 1
42
- rescue StandardError => _
42
+ rescue StandardError => _e
43
43
  http_errors[status] = 1
44
44
  end
45
- rescue StandardError => error
46
- @config.log_found_exception(__method__.to_s, error)
45
+ rescue StandardError => e
46
+ @config.log_found_exception(__method__.to_s, e)
47
47
  end
48
48
 
49
49
  def record_sync_latency(type, bucket)
50
50
  @adapter.http_latencies.find { |l| l[:type] == type }[:value][bucket] += 1
51
- rescue StandardError => error
52
- @config.log_found_exception(__method__.to_s, error)
51
+ rescue StandardError => e
52
+ @config.log_found_exception(__method__.to_s, e)
53
53
  end
54
54
 
55
55
  def record_auth_rejections
56
56
  @adapter.auth_rejections.increment
57
- rescue StandardError => error
58
- @config.log_found_exception(__method__.to_s, error)
57
+ rescue StandardError => e
58
+ @config.log_found_exception(__method__.to_s, e)
59
59
  end
60
60
 
61
61
  def record_token_refreshes
62
62
  @adapter.token_refreshes.increment
63
- rescue StandardError => error
64
- @config.log_found_exception(__method__.to_s, error)
63
+ rescue StandardError => e
64
+ @config.log_found_exception(__method__.to_s, e)
65
65
  end
66
66
 
67
67
  def record_streaming_event(type, data = nil, timestamp = nil)
68
68
  timestamp ||= (Time.now.to_f * 1000.0).to_i
69
69
  @adapter.streaming_events << { e: type, d: data, t: timestamp } unless @adapter.streaming_events.length >= 19
70
- rescue StandardError => error
71
- @config.log_found_exception(__method__.to_s, error)
70
+ rescue StandardError => e
71
+ @config.log_found_exception(__method__.to_s, e)
72
72
  end
73
73
 
74
74
  def record_session_length(session)
75
75
  @adapter.session_length.value = session
76
- rescue StandardError => error
77
- @config.log_found_exception(__method__.to_s, error)
76
+ rescue StandardError => e
77
+ @config.log_found_exception(__method__.to_s, e)
78
78
  end
79
79
  end
80
80
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class MemorySynchronizer < Synchronizer
5
+ class MemorySynchronizer
6
6
  def initialize(config,
7
7
  telemtry_consumers,
8
8
  repositories,
@@ -37,8 +37,8 @@ module SplitIoClient
37
37
  @telemetry_runtime_consumer.pop_tags)
38
38
 
39
39
  @telemetry_api.record_stats(format_stats(usage))
40
- rescue StandardError => error
41
- @config.log_found_exception(__method__.to_s, error)
40
+ rescue StandardError => e
41
+ @config.log_found_exception(__method__.to_s, e)
42
42
  end
43
43
 
44
44
  def synchronize_config(active_factories = nil, redundant_active_factories = nil, time_until_ready = nil)
@@ -75,8 +75,8 @@ module SplitIoClient
75
75
  @telemetry_init_consumer.non_ready_usages)
76
76
 
77
77
  @telemetry_api.record_init(fornat_init_config(init_config))
78
- rescue StandardError => error
79
- @config.log_found_exception(__method__.to_s, error)
78
+ rescue StandardError => e
79
+ @config.log_found_exception(__method__.to_s, e)
80
80
  end
81
81
 
82
82
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class RedisEvaluationProducer < EvaluationProducer
5
+ class RedisEvaluationProducer
6
6
  def initialize(config)
7
7
  @config = config
8
8
  @adapter = config.telemetry_adapter
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class RedisInitProducer < InitProducer
5
+ class RedisInitProducer
6
6
  def initialize(config)
7
7
  @config = config
8
8
  @adapter = config.telemetry_adapter
@@ -30,7 +30,7 @@ module SplitIoClient
30
30
  private
31
31
 
32
32
  def config_key
33
- "#{@config.redis_namespace}.telemetry.config"
33
+ "#{@config.redis_namespace}.telemetry.init"
34
34
  end
35
35
  end
36
36
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module SplitIoClient
4
4
  module Telemetry
5
- class RedisSynchronizer < Synchronizer
5
+ class RedisSynchronizer
6
6
  def initialize(config,
7
7
  telemetry_init_producer)
8
8
  @config = config
@@ -20,8 +20,8 @@ module SplitIoClient
20
20
  init_config = ConfigInit.new(@config.mode, 'redis', active_factories, redundant_active_factories, tags)
21
21
 
22
22
  @telemetry_init_producer.record_config(init_config)
23
- rescue StandardError => error
24
- @config.log_found_exception(__method__.to_s, error)
23
+ rescue StandardError => e
24
+ @config.log_found_exception(__method__.to_s, e)
25
25
  end
26
26
  end
27
27
  end
@@ -15,21 +15,21 @@ module SplitIoClient
15
15
  private
16
16
 
17
17
  def stats_thread
18
- @config.threads[:telemetry_stats_sender] = Thread.new do
19
- begin
20
- @config.logger.info('Starting Telemetry Sync Task')
18
+ @config.threads[:telemetry_stats_sender] = Thread.new { telemetry_sync_task }
19
+ end
21
20
 
22
- loop do
23
- sleep(@config.telemetry_refresh_rate)
21
+ def telemetry_sync_task
22
+ @config.logger.info('Starting Telemetry Sync Task')
24
23
 
25
- @telemetry_synchronizer.synchronize_stats
26
- end
27
- rescue SplitIoClient::SDKShutdownException
28
- @telemetry_synchronizer.synchronize_stats
24
+ loop do
25
+ sleep(@config.telemetry_refresh_rate)
29
26
 
30
- @config.logger.info('Posting Telemetry due to shutdown')
31
- end
27
+ @telemetry_synchronizer.synchronize_stats
32
28
  end
29
+ rescue SplitIoClient::SDKShutdownException
30
+ @telemetry_synchronizer.synchronize_stats
31
+
32
+ @config.logger.info('Posting Telemetry due to shutdown')
33
33
  end
34
34
  end
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module SplitIoClient
2
- VERSION = '7.3.5.pre.rc5'
2
+ VERSION = '8.0.0'
3
3
  end
@@ -49,7 +49,6 @@ require 'splitclient-rb/validators'
49
49
  require 'splitclient-rb/split_factory_registry'
50
50
 
51
51
  require 'splitclient-rb/engine/api/faraday_middleware/gzip'
52
- require 'splitclient-rb/engine/api/faraday_adapter/patched_net_http_persistent'
53
52
  require 'splitclient-rb/engine/api/client'
54
53
  require 'splitclient-rb/engine/api/impressions'
55
54
  require 'splitclient-rb/engine/api/segments'
@@ -8,16 +8,15 @@ Gem::Specification.new do |spec|
8
8
  spec.name = 'splitclient-rb'
9
9
  spec.version = SplitIoClient::VERSION
10
10
  spec.authors = ['Split Software']
11
- spec.email = ['pato@split.io']
12
-
11
+ spec.email = ['mauro.sanz@split.io']
13
12
  spec.summary = 'Ruby client for split SDK.'
14
13
  spec.description = 'Ruby client for using split SDK.'
15
14
  spec.homepage = 'https://github.com/splitio/ruby-client'
16
15
  spec.license = 'Apache-2.0'
17
16
 
18
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features|ext)/}) }
19
-
20
18
  spec.require_paths = ['lib']
19
+ spec.required_ruby_version = '>= 2.5.0'
21
20
 
22
21
  if defined?(JRUBY_VERSION)
23
22
  spec.platform = 'java'
@@ -37,14 +36,13 @@ Gem::Specification.new do |spec|
37
36
  end
38
37
 
39
38
  spec.add_development_dependency 'allocation_stats', '~> 0.1'
40
- spec.add_development_dependency 'appraisal', '~> 2.4'
41
39
  spec.add_development_dependency 'bundler', '~> 2.2'
42
40
  spec.add_development_dependency 'pry', '~> 0.14'
43
41
  spec.add_development_dependency 'pry-nav', '~> 1.0'
44
42
  spec.add_development_dependency 'rake', '~> 13.0'
45
43
  spec.add_development_dependency 'rake-compiler', '~> 1.1'
46
44
  spec.add_development_dependency 'rspec', '~> 3.10'
47
- spec.add_development_dependency 'rubocop', '0.59.0'
45
+ spec.add_development_dependency 'rubocop', '1.28.2'
48
46
  spec.add_development_dependency 'simplecov', '~> 0.20'
49
47
  spec.add_development_dependency 'simplecov-json', '~> 0.2'
50
48
  spec.add_development_dependency 'timecop', '~> 0.9'
@@ -53,7 +51,7 @@ Gem::Specification.new do |spec|
53
51
 
54
52
  spec.add_runtime_dependency 'bitarray', '~> 1.3'
55
53
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
56
- spec.add_runtime_dependency 'faraday', '>= 0.8', '< 2.0'
54
+ spec.add_runtime_dependency 'faraday', '>= 1.1', '< 2.0'
57
55
  spec.add_runtime_dependency 'json', '>= 1.8', '< 3.0'
58
56
  spec.add_runtime_dependency 'jwt', '>= 1.0.0', '< 3.0'
59
57
  spec.add_runtime_dependency 'lru_redux', '~> 1.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splitclient-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.5.pre.rc5
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Split Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-20 00:00:00.000000000 Z
11
+ date: 2022-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allocation_stats
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.1'
27
- - !ruby/object:Gem::Dependency
28
- name: appraisal
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.4'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.4'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +114,14 @@ dependencies:
128
114
  requirements:
129
115
  - - '='
130
116
  - !ruby/object:Gem::Version
131
- version: 0.59.0
117
+ version: 1.28.2
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - '='
137
123
  - !ruby/object:Gem::Version
138
- version: 0.59.0
124
+ version: 1.28.2
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: simplecov
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -240,7 +226,7 @@ dependencies:
240
226
  requirements:
241
227
  - - ">="
242
228
  - !ruby/object:Gem::Version
243
- version: '0.8'
229
+ version: '1.1'
244
230
  - - "<"
245
231
  - !ruby/object:Gem::Version
246
232
  version: '2.0'
@@ -250,7 +236,7 @@ dependencies:
250
236
  requirements:
251
237
  - - ">="
252
238
  - !ruby/object:Gem::Version
253
- version: '0.8'
239
+ version: '1.1'
254
240
  - - "<"
255
241
  - !ruby/object:Gem::Version
256
242
  version: '2.0'
@@ -384,7 +370,7 @@ dependencies:
384
370
  version: '0.3'
385
371
  description: Ruby client for using split SDK.
386
372
  email:
387
- - pato@split.io
373
+ - mauro.sanz@split.io
388
374
  executables: []
389
375
  extensions:
390
376
  - ext/murmurhash/extconf.rb
@@ -396,7 +382,6 @@ files:
396
382
  - ".gitignore"
397
383
  - ".rubocop.yml"
398
384
  - ".simplecov"
399
- - Appraisals
400
385
  - CHANGES.txt
401
386
  - CONTRIBUTORS-GUIDE.md
402
387
  - Gemfile
@@ -451,7 +436,6 @@ files:
451
436
  - lib/splitclient-rb/constants.rb
452
437
  - lib/splitclient-rb/engine/api/client.rb
453
438
  - lib/splitclient-rb/engine/api/events.rb
454
- - lib/splitclient-rb/engine/api/faraday_adapter/patched_net_http_persistent.rb
455
439
  - lib/splitclient-rb/engine/api/faraday_middleware/gzip.rb
456
440
  - lib/splitclient-rb/engine/api/impressions.rb
457
441
  - lib/splitclient-rb/engine/api/segments.rb
@@ -554,14 +538,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
554
538
  requirements:
555
539
  - - ">="
556
540
  - !ruby/object:Gem::Version
557
- version: '0'
541
+ version: 2.5.0
558
542
  required_rubygems_version: !ruby/object:Gem::Requirement
559
543
  requirements:
560
- - - ">"
544
+ - - ">="
561
545
  - !ruby/object:Gem::Version
562
- version: 1.3.1
546
+ version: '0'
563
547
  requirements: []
564
- rubygems_version: 3.2.32
548
+ rubygems_version: 3.3.5
565
549
  signing_key:
566
550
  specification_version: 4
567
551
  summary: Ruby client for split SDK.
data/Appraisals DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise 'faraday-before-0.13' do
4
- gem 'faraday', '>= 0.9', '< 0.13'
5
- gem 'net-http-persistent', '~> 3.0'
6
- end
7
-
8
- appraise 'faraday-after-0.13' do
9
- gem 'faraday', '> 0.13'
10
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SplitIoClient
4
- module FaradayAdapter
5
- class PatchedNetHttpPersistent < Faraday::Adapter::NetHttpPersistent
6
- ##
7
- # Borrowed directly from the latest `NetHttpPersistent` adapter implementation.
8
- #
9
- # https://github.com/lostisland/faraday/blob/master/lib/faraday/adapter/net_http_persistent.rb
10
- #
11
- def net_http_connection(env)
12
- @cached_connection ||=
13
- if Net::HTTP::Persistent.instance_method(:initialize).parameters.first == [:key, :name]
14
- Net::HTTP::Persistent.new(name: 'Faraday')
15
- else
16
- Net::HTTP::Persistent.new('Faraday')
17
- end
18
-
19
- proxy_uri = proxy_uri(env)
20
- @cached_connection.proxy = proxy_uri if @cached_connection.proxy_uri != proxy_uri
21
- @cached_connection
22
- end
23
-
24
- def proxy_uri(env)
25
- proxy_uri = nil
26
- if (proxy = env[:request][:proxy])
27
- proxy_uri = ::URI::HTTP === proxy[:uri] ? proxy[:uri].dup : ::URI.parse(proxy[:uri].to_s)
28
- proxy_uri.user = proxy_uri.password = nil
29
- # awful patch for net-http-persistent 2.8 not unescaping user/password
30
- (
31
- class << proxy_uri;
32
- self;
33
- end).class_eval do
34
- define_method(:user) { proxy[:user] }
35
- define_method(:password) { proxy[:password] }
36
- end if proxy[:user]
37
- end
38
- proxy_uri
39
- end
40
-
41
- def with_net_http_connection(env)
42
- yield net_http_connection(env)
43
- end
44
- end
45
- end
46
- end