splitclient-rb 8.1.2-java → 8.1.3.pre.rc1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/splitclient-rb/helpers/decryption_helper.rb +25 -0
- data/lib/splitclient-rb/sse/notification_processor.rb +2 -6
- data/lib/splitclient-rb/sse/workers/splits_worker.rb +46 -14
- data/lib/splitclient-rb/version.rb +1 -1
- data/lib/splitclient-rb.rb +1 -0
- data/splitclient-rb.gemspec +1 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aeedfe4b86ecd8ca68ce4a5f309758f48f7cbc1
|
4
|
+
data.tar.gz: b1c284a4d23b41582e0e58fd8f827b10e13490d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cea9bc6609a23fd184f1e406fac905b06e1df66db297027b28ada289e17d7d46be7f58b4f7a8a2f26ff04287e146344b606c0a284c4acba8d537fa262fbad867
|
7
|
+
data.tar.gz: a26df41524283c15ddc5935b8151a533624b56bd71e24f6d6c0514f024281b77ee970314b8c36f52c4922dc5574b8998adccd298a0e96a0050b16b008bd9ee51
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SplitIoClient
|
4
|
+
NO_COMPRESSION = 0
|
5
|
+
GZIP_COMPRESSION = 1
|
6
|
+
ZLIB_COMPRESSION = 2
|
7
|
+
|
8
|
+
module Helpers
|
9
|
+
class DecryptionHelper
|
10
|
+
def self.get_encoded_definition(compression, data)
|
11
|
+
case compression
|
12
|
+
when NO_COMPRESSION
|
13
|
+
Base64.decode64(data)
|
14
|
+
when GZIP_COMPRESSION
|
15
|
+
gz = Zlib::GzipReader.new(StringIO.new(Base64.decode64(data)))
|
16
|
+
gz.read
|
17
|
+
when ZLIB_COMPRESSION
|
18
|
+
Zlib::Inflate.inflate(Base64.decode64(data))
|
19
|
+
else
|
20
|
+
raise StandardError, 'Compression flag value is incorrect'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -26,16 +26,12 @@ module SplitIoClient
|
|
26
26
|
|
27
27
|
def process_split_update(notification)
|
28
28
|
@config.logger.debug("SPLIT UPDATE notification received: #{notification}") if @config.debug_enabled
|
29
|
-
@splits_worker.add_to_queue(notification
|
29
|
+
@splits_worker.add_to_queue(notification)
|
30
30
|
end
|
31
31
|
|
32
32
|
def process_split_kill(notification)
|
33
33
|
@config.logger.debug("SPLIT KILL notification received: #{notification}") if @config.debug_enabled
|
34
|
-
|
35
|
-
default_treatment = notification.data['defaultTreatment']
|
36
|
-
split_name = notification.data['splitName']
|
37
|
-
|
38
|
-
@splits_worker.kill_split(change_number, split_name, default_treatment)
|
34
|
+
@splits_worker.add_to_queue(notification)
|
39
35
|
end
|
40
36
|
|
41
37
|
def process_segment_update(notification)
|
@@ -4,10 +4,10 @@ module SplitIoClient
|
|
4
4
|
module SSE
|
5
5
|
module Workers
|
6
6
|
class SplitsWorker
|
7
|
-
def initialize(synchronizer, config,
|
7
|
+
def initialize(synchronizer, config, feature_flags_repository)
|
8
8
|
@synchronizer = synchronizer
|
9
9
|
@config = config
|
10
|
-
@
|
10
|
+
@feature_flags_repository = feature_flags_repository
|
11
11
|
@queue = Queue.new
|
12
12
|
@running = Concurrent::AtomicBoolean.new(false)
|
13
13
|
end
|
@@ -32,25 +32,57 @@ module SplitIoClient
|
|
32
32
|
SplitIoClient::Helpers::ThreadHelper.stop(:split_update_worker, @config)
|
33
33
|
end
|
34
34
|
|
35
|
-
def add_to_queue(
|
36
|
-
@config.logger.debug("feature_flags_worker add to queue #{
|
37
|
-
@queue.push(
|
35
|
+
def add_to_queue(notification)
|
36
|
+
@config.logger.debug("feature_flags_worker add to queue #{notification.data['changeNumber']}")
|
37
|
+
@queue.push(notification)
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
private
|
41
|
+
|
42
|
+
def update_feature_flag(notification)
|
43
|
+
return if @feature_flags_repository.get_change_number.to_i > notification.data['changeNumber']
|
42
44
|
|
43
|
-
@
|
44
|
-
|
45
|
-
|
45
|
+
if @feature_flags_repository.get_change_number == notification.data['pcn']
|
46
|
+
begin
|
47
|
+
@feature_flags_repository.add_split(
|
48
|
+
JSON.parse(
|
49
|
+
SplitIoClient::Helpers::DecryptionHelper.get_encoded_definition(
|
50
|
+
notification.data['c'],
|
51
|
+
notification.data['d']
|
52
|
+
),
|
53
|
+
symbolize_names: true
|
54
|
+
)
|
55
|
+
)
|
56
|
+
@feature_flags_repository.set_change_number(notification.data['changeNumber'])
|
57
|
+
return
|
58
|
+
rescue StandardError => e
|
59
|
+
@config.logger.debug("Failed to update Split: #{e.inspect}") if @config.debug_enabled
|
60
|
+
end
|
61
|
+
end
|
62
|
+
@synchronizer.fetch_splits(notification.data['changeNumber'])
|
46
63
|
end
|
47
64
|
|
48
|
-
|
65
|
+
def kill_feature_flag(notification)
|
66
|
+
return if @feature_flags_repository.get_change_number.to_i > notification.data['changeNumber']
|
67
|
+
|
68
|
+
@config.logger.debug("feature_flags_worker kill #{notification.data['splitName']}, #{notification.data['changeNumber']}")
|
69
|
+
@feature_flags_repository.kill(
|
70
|
+
notification.data['changeNumber'],
|
71
|
+
notification.data['splitName'],
|
72
|
+
notification.data['defaultTreatment']
|
73
|
+
)
|
74
|
+
@synchronizer.fetch_splits(notification.data['changeNumber'])
|
75
|
+
end
|
49
76
|
|
50
77
|
def perform
|
51
|
-
while (
|
52
|
-
@config.logger.debug("feature_flags_worker change_number dequeue #{
|
53
|
-
|
78
|
+
while (notification = @queue.pop)
|
79
|
+
@config.logger.debug("feature_flags_worker change_number dequeue #{notification.data['changeNumber']}")
|
80
|
+
case notification.data['type']
|
81
|
+
when SSE::EventSource::EventTypes::SPLIT_UPDATE
|
82
|
+
update_feature_flag(notification)
|
83
|
+
when SSE::EventSource::EventTypes::SPLIT_KILL
|
84
|
+
kill_feature_flag(notification)
|
85
|
+
end
|
54
86
|
end
|
55
87
|
end
|
56
88
|
|
data/lib/splitclient-rb.rb
CHANGED
@@ -41,6 +41,7 @@ require 'splitclient-rb/cache/stores/store_utils'
|
|
41
41
|
require 'splitclient-rb/clients/split_client'
|
42
42
|
require 'splitclient-rb/managers/split_manager'
|
43
43
|
require 'splitclient-rb/helpers/thread_helper'
|
44
|
+
require 'splitclient-rb/helpers/decryption_helper'
|
44
45
|
require 'splitclient-rb/split_factory'
|
45
46
|
require 'splitclient-rb/split_factory_builder'
|
46
47
|
require 'splitclient-rb/split_config'
|
data/splitclient-rb.gemspec
CHANGED
@@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
|
|
48
48
|
spec.add_development_dependency 'timecop', '~> 0.9'
|
49
49
|
spec.add_development_dependency 'webmock', '~> 3.14'
|
50
50
|
spec.add_development_dependency 'webrick', '~> 1.7'
|
51
|
+
spec.add_development_dependency 'byebug', '~> 11.1'
|
51
52
|
|
52
53
|
spec.add_runtime_dependency 'bitarray', '~> 1.3'
|
53
54
|
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
|
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: 8.1.
|
4
|
+
version: 8.1.3.pre.rc1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Split Software
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '1.7'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
requirement: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '11.1'
|
201
|
+
name: byebug
|
202
|
+
prerelease: false
|
203
|
+
type: :development
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '11.1'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
requirement: !ruby/object:Gem::Requirement
|
197
211
|
requirements:
|
@@ -498,6 +512,7 @@ files:
|
|
498
512
|
- lib/splitclient-rb/engine/sync_manager.rb
|
499
513
|
- lib/splitclient-rb/engine/synchronizer.rb
|
500
514
|
- lib/splitclient-rb/exceptions.rb
|
515
|
+
- lib/splitclient-rb/helpers/decryption_helper.rb
|
501
516
|
- lib/splitclient-rb/helpers/thread_helper.rb
|
502
517
|
- lib/splitclient-rb/managers/split_manager.rb
|
503
518
|
- lib/splitclient-rb/split_config.rb
|
@@ -557,9 +572,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
557
572
|
version: 2.5.0
|
558
573
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
559
574
|
requirements:
|
560
|
-
- - "
|
575
|
+
- - ">"
|
561
576
|
- !ruby/object:Gem::Version
|
562
|
-
version:
|
577
|
+
version: 1.3.1
|
563
578
|
requirements: []
|
564
579
|
rubyforge_project:
|
565
580
|
rubygems_version: 2.6.14
|