ff-ruby-server-sdk 1.4.1 → 1.4.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d40a21b8332b96f4c3f507f2adece4bc12a9475fb87518323c3b79f959d2782a
|
4
|
+
data.tar.gz: 4be776d630a6c97cc563e801b74b8c25e6250ea3611fa83b6a1b26274ead4d06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d11cd5ae4daddce986eae1faa3ca10d16e68a0c708e4e15131d0ee74883e67bac88af39cedfa1ee5497f7ac916bfd270bd8067bcbf71c3e90de242520ff49cd1
|
7
|
+
data.tar.gz: bfc9bc6662bc500c25281c36bb9d8352ba16bdf8ad9f43c06b44074aa4ff791e2ddb8e1e84b1796bd4fb10bfe819190d6eb33bde7ac315eff02e918784653fcb
|
@@ -1,56 +1,23 @@
|
|
1
|
-
|
1
|
+
require 'singleton'
|
2
2
|
require_relative "../../generated/lib/openapi_client"
|
3
3
|
require_relative "../common/closeable"
|
4
4
|
require_relative "inner_client"
|
5
5
|
|
6
6
|
class CfClient < Closeable
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@@instance
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def init(api_key, config, connector = nil)
|
10
|
+
# Only initialize if @client is nil to avoid reinitialization
|
11
|
+
unless @client
|
12
|
+
@config = config || ConfigBuilder.new.build
|
13
|
+
@client = InnerClient.new(api_key, @config, connector)
|
14
|
+
@config.logger.debug "Client initialized with API key: #{api_key}"
|
16
15
|
end
|
16
|
+
@client
|
17
17
|
end
|
18
18
|
|
19
|
-
# Static - End
|
20
|
-
|
21
|
-
def initialize(api_key = nil, config = nil, connector = nil)
|
22
|
-
|
23
|
-
if config == nil
|
24
|
-
|
25
|
-
@config = ConfigBuilder.new.build
|
26
|
-
else
|
27
|
-
|
28
|
-
@config = config
|
29
|
-
end
|
30
|
-
|
31
|
-
@client = InnerClient.new(api_key, config, connector)
|
32
|
-
|
33
|
-
@config.logger.debug "Client (1): " + @client.to_s
|
34
|
-
end
|
35
|
-
|
36
|
-
def init(api_key = nil, config = nil, connector = nil)
|
37
|
-
|
38
|
-
if @client == nil
|
39
|
-
|
40
|
-
@config = config
|
41
|
-
|
42
|
-
@client = InnerClient.new(
|
43
|
-
|
44
|
-
api_key = api_key,
|
45
|
-
config = config,
|
46
|
-
connector = connector
|
47
|
-
)
|
48
|
-
|
49
|
-
@config.logger.debug "Client (2): " + @client.to_s
|
50
|
-
end
|
51
|
-
end
|
52
19
|
|
53
|
-
|
20
|
+
def wait_for_initialization(timeout_ms: nil)
|
54
21
|
if @client != nil
|
55
22
|
@client.wait_for_initialization(timeout: timeout_ms)
|
56
23
|
end
|
@@ -78,6 +78,8 @@ class MetricsProcessor < Closeable
|
|
78
78
|
|
79
79
|
@executor = Concurrent::FixedThreadPool.new(10)
|
80
80
|
|
81
|
+
# Used for locking the evalution and target metrics maps before we clone them
|
82
|
+
@metric_maps_mutex = Mutex.new
|
81
83
|
@evaluation_metrics = FrequencyMap.new
|
82
84
|
@target_metrics = Concurrent::Map.new
|
83
85
|
|
@@ -181,21 +183,27 @@ class MetricsProcessor < Closeable
|
|
181
183
|
end
|
182
184
|
|
183
185
|
def send_data_and_reset_cache(evaluation_metrics_map, target_metrics_map)
|
184
|
-
|
186
|
+
|
185
187
|
evaluation_metrics_map_clone = Concurrent::Map.new
|
188
|
+
target_metrics_map_clone = Concurrent::Map.new
|
186
189
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
+
# A single lock is used to synchronise access to both the evaluation and target metrics maps.
|
191
|
+
# While separate locks could be applied to each map individually, we want an interval's eval/target
|
192
|
+
# metrics to be processed in an atomic unit.
|
193
|
+
@metric_maps_mutex.synchronize do
|
194
|
+
# Clone and clear evaluation metrics map
|
195
|
+
evaluation_metrics_map.each_pair do |key, value|
|
196
|
+
evaluation_metrics_map_clone[key] = value
|
197
|
+
end
|
190
198
|
|
191
|
-
|
192
|
-
target_metrics_map_clone = Concurrent::Map.new
|
199
|
+
evaluation_metrics_map.clear
|
193
200
|
|
194
|
-
|
195
|
-
|
196
|
-
|
201
|
+
target_metrics_map.each_pair do |key, value|
|
202
|
+
target_metrics_map_clone[key] = value
|
203
|
+
end
|
197
204
|
|
198
|
-
|
205
|
+
target_metrics_map.clear
|
206
|
+
end
|
199
207
|
|
200
208
|
@evaluation_warning_issued.make_false
|
201
209
|
@target_warning_issued.make_false
|
data/scripts/sdk_specs.sh
CHANGED