splitclient-rb 8.1.3.pre.rc3-java → 8.1.3.pre.rc4-java
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/.github/workflows/ci.yml +3 -3
- data/lib/splitclient-rb/engine/api/splits.rb +1 -11
- data/lib/splitclient-rb/helpers/util.rb +17 -0
- data/lib/splitclient-rb/split_factory.rb +1 -1
- data/lib/splitclient-rb/sse/workers/splits_worker.rb +48 -42
- data/lib/splitclient-rb/telemetry/domain/constants.rb +2 -0
- data/lib/splitclient-rb/telemetry/domain/structs.rb +5 -2
- data/lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb +7 -0
- data/lib/splitclient-rb/telemetry/memory/memory_runtime_producer.rb +6 -0
- data/lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb +4 -2
- data/lib/splitclient-rb/telemetry/runtime_consumer.rb +2 -1
- data/lib/splitclient-rb/telemetry/runtime_producer.rb +2 -1
- data/lib/splitclient-rb/telemetry/storages/memory.rb +9 -1
- data/lib/splitclient-rb/version.rb +1 -1
- data/lib/splitclient-rb.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8753013ccb2e60edf514115dd808c531a55f0bb0
|
4
|
+
data.tar.gz: 258ea4f4543ca8a977f0e662fd4f156cf3a39698
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1869e634836e8fd54847aaa7b03a9d916f1650a616bb4da85cd7b56ff0879b5af3b03f07da66a1717e663d823b10d3e50d0245aeb66e3e727fdff8bd71f78ea5
|
7
|
+
data.tar.gz: f6ba403082dc072594565f22785c2c3cbcc8c7b027716570e0321ac28a6591a0b4348de0bac969bce84caf480964902b755364afeda3b8e5d22f1e79c62f2c8f
|
data/.github/workflows/ci.yml
CHANGED
@@ -27,7 +27,7 @@ jobs:
|
|
27
27
|
matrix:
|
28
28
|
version:
|
29
29
|
- '2.5.0'
|
30
|
-
- '3.
|
30
|
+
- '3.2.2'
|
31
31
|
|
32
32
|
steps:
|
33
33
|
- name: Checkout code
|
@@ -56,7 +56,7 @@ jobs:
|
|
56
56
|
run: echo "VERSION=$(cat lib/splitclient-rb/version.rb | grep VERSION | awk -F "'" '{print $2}')" >> $GITHUB_ENV
|
57
57
|
|
58
58
|
- name: SonarQube Scan (Push)
|
59
|
-
if: matrix.version == '3.
|
59
|
+
if: matrix.version == '3.2.2' && github.event_name == 'push'
|
60
60
|
uses: SonarSource/sonarcloud-github-action@v1.9
|
61
61
|
env:
|
62
62
|
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
@@ -68,7 +68,7 @@ jobs:
|
|
68
68
|
-Dsonar.projectVersion=${{ env.VERSION }}
|
69
69
|
|
70
70
|
- name: SonarQube Scan (Pull Request)
|
71
|
-
if: matrix.version == '3.
|
71
|
+
if: matrix.version == '3.2.2' && github.event_name == 'pull_request'
|
72
72
|
uses: SonarSource/sonarcloud-github-action@v1.9
|
73
73
|
env:
|
74
74
|
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
|
@@ -46,21 +46,11 @@ module SplitIoClient
|
|
46
46
|
|
47
47
|
parsed_splits[:segment_names] =
|
48
48
|
parsed_splits[:splits].each_with_object(Set.new) do |split, splits|
|
49
|
-
splits <<
|
49
|
+
splits << Helpers::Util.segment_names_by_feature_flag(split)
|
50
50
|
end.flatten
|
51
51
|
|
52
52
|
parsed_splits
|
53
53
|
end
|
54
|
-
|
55
|
-
def segment_names(split)
|
56
|
-
split[:conditions].each_with_object(Set.new) do |condition, names|
|
57
|
-
condition[:matcherGroup][:matchers].each do |matcher|
|
58
|
-
next if matcher[:userDefinedSegmentMatcherData].nil?
|
59
|
-
|
60
|
-
names << matcher[:userDefinedSegmentMatcherData][:segmentName]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
54
|
end
|
65
55
|
end
|
66
56
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SplitIoClient
|
4
|
+
module Helpers
|
5
|
+
class Util
|
6
|
+
def self.segment_names_by_feature_flag(feature_flag)
|
7
|
+
feature_flag[:conditions].each_with_object(Set.new) do |condition, names|
|
8
|
+
condition[:matcherGroup][:matchers].each do |matcher|
|
9
|
+
next if matcher[:userDefinedSegmentMatcherData].nil?
|
10
|
+
|
11
|
+
names << matcher[:userDefinedSegmentMatcherData][:segmentName]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -184,7 +184,7 @@ module SplitIoClient
|
|
184
184
|
|
185
185
|
def build_streaming_components
|
186
186
|
@push_status_queue = Queue.new
|
187
|
-
splits_worker = SSE::Workers::SplitsWorker.new(@synchronizer, @config, @splits_repository)
|
187
|
+
splits_worker = SSE::Workers::SplitsWorker.new(@synchronizer, @config, @splits_repository, @runtime_producer, @segment_fetcher)
|
188
188
|
segments_worker = SSE::Workers::SegmentsWorker.new(@synchronizer, @config, @segments_repository)
|
189
189
|
notification_manager_keeper = SSE::NotificationManagerKeeper.new(@config, @runtime_producer, @push_status_queue)
|
190
190
|
notification_processor = SSE::NotificationProcessor.new(@config, splits_worker, segments_worker)
|
@@ -4,12 +4,14 @@ module SplitIoClient
|
|
4
4
|
module SSE
|
5
5
|
module Workers
|
6
6
|
class SplitsWorker
|
7
|
-
def initialize(synchronizer, config, feature_flags_repository)
|
7
|
+
def initialize(synchronizer, config, feature_flags_repository, telemetry_runtime_producer, segment_fetcher)
|
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
|
+
@telemetry_runtime_producer = telemetry_runtime_producer
|
14
|
+
@segment_fetcher = segment_fetcher
|
13
15
|
end
|
14
16
|
|
15
17
|
def start
|
@@ -29,7 +31,7 @@ module SplitIoClient
|
|
29
31
|
end
|
30
32
|
|
31
33
|
@running.make_false
|
32
|
-
|
34
|
+
Helpers::ThreadHelper.stop(:split_update_worker, @config)
|
33
35
|
end
|
34
36
|
|
35
37
|
def add_to_queue(notification)
|
@@ -39,38 +41,47 @@ module SplitIoClient
|
|
39
41
|
|
40
42
|
private
|
41
43
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
),
|
48
|
-
symbolize_names: true
|
49
|
-
)
|
44
|
+
def perform_thread
|
45
|
+
@config.threads[:split_update_worker] = Thread.new do
|
46
|
+
@config.logger.debug('starting feature_flags_worker ...') if @config.debug_enabled
|
47
|
+
perform
|
48
|
+
end
|
50
49
|
end
|
51
50
|
|
52
|
-
def
|
53
|
-
|
51
|
+
def perform
|
52
|
+
while (notification = @queue.pop)
|
53
|
+
@config.logger.debug("feature_flags_worker change_number dequeue #{notification.data['changeNumber']}")
|
54
|
+
case notification.data['type']
|
55
|
+
when SSE::EventSource::EventTypes::SPLIT_UPDATE
|
56
|
+
success = update_feature_flag(notification)
|
57
|
+
@synchronizer.fetch_splits(notification.data['changeNumber']) unless success
|
58
|
+
when SSE::EventSource::EventTypes::SPLIT_KILL
|
59
|
+
kill_feature_flag(notification)
|
60
|
+
end
|
61
|
+
end
|
54
62
|
end
|
55
63
|
|
56
64
|
def update_feature_flag(notification)
|
57
|
-
return if @feature_flags_repository.get_change_number.to_i
|
65
|
+
return true if @feature_flags_repository.get_change_number.to_i >= notification.data['changeNumber']
|
66
|
+
return false unless !notification.data['d'].nil? && @feature_flags_repository.get_change_number == notification.data['pcn']
|
58
67
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
@feature_flags_repository.set_change_number(notification.data['changeNumber'])
|
68
|
-
return
|
69
|
-
rescue StandardError => e
|
70
|
-
@config.logger.debug("Failed to update Split: #{e.inspect}") if @config.debug_enabled
|
71
|
-
end
|
68
|
+
new_split = return_split_from_json(notification)
|
69
|
+
if Engine::Models::Split.archived?(new_split)
|
70
|
+
@feature_flags_repository.remove_split(new_split)
|
71
|
+
else
|
72
|
+
@feature_flags_repository.add_split(new_split)
|
73
|
+
|
74
|
+
fetch_segments_if_not_exists(new_split)
|
72
75
|
end
|
73
|
-
|
76
|
+
|
77
|
+
@feature_flags_repository.set_change_number(notification.data['changeNumber'])
|
78
|
+
@telemetry_runtime_producer.record_updates_from_sse(Telemetry::Domain::Constants::SPLITS)
|
79
|
+
|
80
|
+
true
|
81
|
+
rescue StandardError => e
|
82
|
+
@config.logger.debug("Failed to update Split: #{e.inspect}") if @config.debug_enabled
|
83
|
+
|
84
|
+
false
|
74
85
|
end
|
75
86
|
|
76
87
|
def kill_feature_flag(notification)
|
@@ -85,23 +96,18 @@ module SplitIoClient
|
|
85
96
|
@synchronizer.fetch_splits(notification.data['changeNumber'])
|
86
97
|
end
|
87
98
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
when SSE::EventSource::EventTypes::SPLIT_UPDATE
|
93
|
-
update_feature_flag(notification)
|
94
|
-
when SSE::EventSource::EventTypes::SPLIT_KILL
|
95
|
-
kill_feature_flag(notification)
|
96
|
-
end
|
97
|
-
end
|
99
|
+
def return_split_from_json(notification)
|
100
|
+
split_json = Helpers::DecryptionHelper.get_encoded_definition(notification.data['c'], notification.data['d'])
|
101
|
+
|
102
|
+
JSON.parse(split_json, symbolize_names: true)
|
98
103
|
end
|
99
104
|
|
100
|
-
def
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
+
def fetch_segments_if_not_exists(feature_flag)
|
106
|
+
segment_names = Helpers::Util.segment_names_by_feature_flag(feature_flag)
|
107
|
+
return if segment_names.nil?
|
108
|
+
|
109
|
+
@feature_flags_repository.set_segment_names(segment_names)
|
110
|
+
@segment_fetcher.fetch_segments_if_not_exists(segment_names)
|
105
111
|
end
|
106
112
|
end
|
107
113
|
end
|
@@ -22,11 +22,14 @@ module SplitIoClient
|
|
22
22
|
# ls: lastSynchronization, ml: clientMethodLatencies, me: clientMethodExceptions, he: httpErros, hl: httpLatencies,
|
23
23
|
# tr: tokenRefreshes, ar: authRejections, iq: impressionsQueued, ide: impressionsDeduped, idr: impressionsDropped,
|
24
24
|
# spc: splitsCount, sec: segmentCount, skc: segmentKeyCount, sl: sessionLengthMs, eq: eventsQueued, ed: eventsDropped,
|
25
|
-
# se: streamingEvents, t: tags
|
26
|
-
Usage = Struct.new(:ls, :ml, :me, :he, :hl, :tr, :ar, :iq, :ide, :idr, :spc, :sec, :skc, :sl, :eq, :ed, :se, :t)
|
25
|
+
# se: streamingEvents, t: tags, ufs: updates from sse
|
26
|
+
Usage = Struct.new(:ls, :ml, :me, :he, :hl, :tr, :ar, :iq, :ide, :idr, :spc, :sec, :skc, :sl, :eq, :ed, :se, :t, :ufs)
|
27
27
|
|
28
28
|
# t: treatment, ts: treatments, tc: treatmentWithConfig, tcs: treatmentsWithConfig, tr: track
|
29
29
|
ClientMethodLatencies = Struct.new(:t, :ts, :tc, :tcs, :tr)
|
30
30
|
ClientMethodExceptions = Struct.new(:t, :ts, :tc, :tcs, :tr)
|
31
|
+
|
32
|
+
# sp: splits
|
33
|
+
UpdatesFromSSE = Struct.new(:sp)
|
31
34
|
end
|
32
35
|
end
|
@@ -94,6 +94,13 @@ module SplitIoClient
|
|
94
94
|
@adapter.session_length.value
|
95
95
|
end
|
96
96
|
|
97
|
+
def pop_updates_from_sse
|
98
|
+
splits = @adapter.updates_from_sse[Domain::Constants::SPLITS]
|
99
|
+
@adapter.updates_from_sse[Domain::Constants::SPLITS] = 0
|
100
|
+
|
101
|
+
UpdatesFromSSE.new(splits)
|
102
|
+
end
|
103
|
+
|
97
104
|
private
|
98
105
|
|
99
106
|
def find_last_synchronization(type)
|
@@ -76,6 +76,12 @@ module SplitIoClient
|
|
76
76
|
rescue StandardError => e
|
77
77
|
@config.log_found_exception(__method__.to_s, e)
|
78
78
|
end
|
79
|
+
|
80
|
+
def record_updates_from_sse(event)
|
81
|
+
@adapter.updates_from_sse[event] += 1
|
82
|
+
rescue StandardError => e
|
83
|
+
@config.log_found_exception(__method__.to_s, e)
|
84
|
+
end
|
79
85
|
end
|
80
86
|
end
|
81
87
|
end
|
@@ -34,7 +34,8 @@ module SplitIoClient
|
|
34
34
|
@telemetry_runtime_consumer.events_stats(Domain::Constants::EVENTS_QUEUED),
|
35
35
|
@telemetry_runtime_consumer.events_stats(Domain::Constants::EVENTS_DROPPED),
|
36
36
|
@telemetry_runtime_consumer.pop_streaming_events,
|
37
|
-
@telemetry_runtime_consumer.pop_tags
|
37
|
+
@telemetry_runtime_consumer.pop_tags,
|
38
|
+
@telemetry_runtime_consumer.pop_updates_from_sse)
|
38
39
|
|
39
40
|
@telemetry_api.record_stats(format_stats(usage))
|
40
41
|
rescue StandardError => e
|
@@ -163,7 +164,8 @@ module SplitIoClient
|
|
163
164
|
eQ: usage.eq,
|
164
165
|
eD: usage.ed,
|
165
166
|
sE: usage.se,
|
166
|
-
t: usage.t
|
167
|
+
t: usage.t,
|
168
|
+
ufs: usage.ufs.to_h
|
167
169
|
}
|
168
170
|
end
|
169
171
|
|
@@ -14,7 +14,8 @@ module SplitIoClient
|
|
14
14
|
:pop_auth_rejections,
|
15
15
|
:pop_token_refreshes,
|
16
16
|
:pop_streaming_events,
|
17
|
-
:session_length
|
17
|
+
:session_length,
|
18
|
+
:pop_updates_from_sse
|
18
19
|
|
19
20
|
def initialize(config)
|
20
21
|
@runtime = SplitIoClient::Telemetry::MemoryRuntimeConsumer.new(config)
|
@@ -14,7 +14,8 @@ module SplitIoClient
|
|
14
14
|
:record_auth_rejections,
|
15
15
|
:record_token_refreshes,
|
16
16
|
:record_streaming_event,
|
17
|
-
:record_session_length
|
17
|
+
:record_session_length,
|
18
|
+
:record_updates_from_sse
|
18
19
|
|
19
20
|
def initialize(config)
|
20
21
|
@runtime = SplitIoClient::Telemetry::MemoryRuntimeProducer.new(config)
|
@@ -16,7 +16,8 @@ module SplitIoClient
|
|
16
16
|
:auth_rejections,
|
17
17
|
:token_refreshes,
|
18
18
|
:streaming_events,
|
19
|
-
:session_length
|
19
|
+
:session_length,
|
20
|
+
:updates_from_sse
|
20
21
|
|
21
22
|
def initialize
|
22
23
|
init_latencies
|
@@ -32,6 +33,7 @@ module SplitIoClient
|
|
32
33
|
init_streaming_events
|
33
34
|
init_session_length
|
34
35
|
init_tags
|
36
|
+
init_updates_from_sse
|
35
37
|
end
|
36
38
|
|
37
39
|
def init_latencies
|
@@ -133,6 +135,12 @@ module SplitIoClient
|
|
133
135
|
def init_session_length
|
134
136
|
@session_length = Concurrent::AtomicFixnum.new(0)
|
135
137
|
end
|
138
|
+
|
139
|
+
def init_updates_from_sse
|
140
|
+
@updates_from_sse = Concurrent::Hash.new
|
141
|
+
|
142
|
+
@updates_from_sse[Domain::Constants::SPLITS] = 0
|
143
|
+
end
|
136
144
|
end
|
137
145
|
end
|
138
146
|
end
|
data/lib/splitclient-rb.rb
CHANGED
@@ -42,6 +42,7 @@ require 'splitclient-rb/clients/split_client'
|
|
42
42
|
require 'splitclient-rb/managers/split_manager'
|
43
43
|
require 'splitclient-rb/helpers/thread_helper'
|
44
44
|
require 'splitclient-rb/helpers/decryption_helper'
|
45
|
+
require 'splitclient-rb/helpers/util'
|
45
46
|
require 'splitclient-rb/split_factory'
|
46
47
|
require 'splitclient-rb/split_factory_builder'
|
47
48
|
require 'splitclient-rb/split_config'
|
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.3.pre.
|
4
|
+
version: 8.1.3.pre.rc4
|
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-06-
|
11
|
+
date: 2023-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -514,6 +514,7 @@ files:
|
|
514
514
|
- lib/splitclient-rb/exceptions.rb
|
515
515
|
- lib/splitclient-rb/helpers/decryption_helper.rb
|
516
516
|
- lib/splitclient-rb/helpers/thread_helper.rb
|
517
|
+
- lib/splitclient-rb/helpers/util.rb
|
517
518
|
- lib/splitclient-rb/managers/split_manager.rb
|
518
519
|
- lib/splitclient-rb/split_config.rb
|
519
520
|
- lib/splitclient-rb/split_factory.rb
|