configdirector-server-sdk 0.1.0
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 +7 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +254 -0
- data/LICENSE +21 -0
- data/README.md +230 -0
- data/lib/configdirector/client_hooks.rb +46 -0
- data/lib/configdirector/config_director_client.rb +322 -0
- data/lib/configdirector/config_evaluated_event.rb +10 -0
- data/lib/configdirector/config_evaluation.rb +51 -0
- data/lib/configdirector/config_state.rb +39 -0
- data/lib/configdirector/configs_updated_event.rb +23 -0
- data/lib/configdirector/connection_error_event.rb +11 -0
- data/lib/configdirector/connection_options.rb +60 -0
- data/lib/configdirector/context.rb +53 -0
- data/lib/configdirector/errors.rb +29 -0
- data/lib/configdirector/internal/client/client_connection.rb +119 -0
- data/lib/configdirector/internal/client/client_factory.rb +104 -0
- data/lib/configdirector/internal/client/client_options_validation.rb +53 -0
- data/lib/configdirector/internal/client/config_read.rb +31 -0
- data/lib/configdirector/internal/client/config_reader.rb +55 -0
- data/lib/configdirector/internal/client/connection_intake.rb +59 -0
- data/lib/configdirector/internal/client/connection_options_validation.rb +94 -0
- data/lib/configdirector/internal/client/context_admission.rb +48 -0
- data/lib/configdirector/internal/client/context_attributes.rb +78 -0
- data/lib/configdirector/internal/client/context_kind.rb +24 -0
- data/lib/configdirector/internal/client/evaluated_read.rb +9 -0
- data/lib/configdirector/internal/client/event_handlers.rb +114 -0
- data/lib/configdirector/internal/client/event_tracking.rb +39 -0
- data/lib/configdirector/internal/client/live_client_connections.rb +58 -0
- data/lib/configdirector/internal/client/number_of_seconds.rb +21 -0
- data/lib/configdirector/internal/client/registrations.rb +43 -0
- data/lib/configdirector/internal/client/restart_in_forked_processes.rb +25 -0
- data/lib/configdirector/internal/client/served_configs.rb +83 -0
- data/lib/configdirector/internal/client/serving_state.rb +102 -0
- data/lib/configdirector/internal/client/watches.rb +51 -0
- data/lib/configdirector/internal/client/what_follows_a_fork.rb +24 -0
- data/lib/configdirector/internal/connection/condition_parser.rb +74 -0
- data/lib/configdirector/internal/connection/config_definition.rb +37 -0
- data/lib/configdirector/internal/connection/http_session.rb +15 -0
- data/lib/configdirector/internal/connection/in_memory_connection.rb +134 -0
- data/lib/configdirector/internal/connection/json_post_request.rb +24 -0
- data/lib/configdirector/internal/connection/not_a_server_sdk_payload.rb +9 -0
- data/lib/configdirector/internal/connection/offline_mode_connection.rb +96 -0
- data/lib/configdirector/internal/connection/offline_values_file.rb +49 -0
- data/lib/configdirector/internal/connection/payloads_delivered_in_turn.rb +46 -0
- data/lib/configdirector/internal/connection/polling_interval.rb +21 -0
- data/lib/configdirector/internal/connection/request_deadline.rb +45 -0
- data/lib/configdirector/internal/connection/retry_after_header.rb +24 -0
- data/lib/configdirector/internal/connection/server_sdk_payload.rb +37 -0
- data/lib/configdirector/internal/connection/server_sdk_payload_parser.rb +89 -0
- data/lib/configdirector/internal/connection/targeting_rules_parser.rb +70 -0
- data/lib/configdirector/internal/connection/test_client_initializations.rb +111 -0
- data/lib/configdirector/internal/connection/test_client_values.rb +53 -0
- data/lib/configdirector/internal/connection/unreadable_definition.rb +9 -0
- data/lib/configdirector/internal/connection/wire_fields.rb +59 -0
- data/lib/configdirector/internal/evaluation/array_comparison.rb +25 -0
- data/lib/configdirector/internal/evaluation/assigned_percentage.rb +21 -0
- data/lib/configdirector/internal/evaluation/attribute_condition.rb +48 -0
- data/lib/configdirector/internal/evaluation/config_evaluator.rb +29 -0
- data/lib/configdirector/internal/evaluation/datetime_comparison.rb +93 -0
- data/lib/configdirector/internal/evaluation/evaluation_context.rb +17 -0
- data/lib/configdirector/internal/evaluation/number_comparison.rb +119 -0
- data/lib/configdirector/internal/evaluation/rapidhash.rb +124 -0
- data/lib/configdirector/internal/evaluation/rollout_share.rb +9 -0
- data/lib/configdirector/internal/evaluation/rule.rb +70 -0
- data/lib/configdirector/internal/evaluation/scalar_text.rb +70 -0
- data/lib/configdirector/internal/evaluation/segment.rb +17 -0
- data/lib/configdirector/internal/evaluation/segment_condition.rb +26 -0
- data/lib/configdirector/internal/evaluation/semver_comparison.rb +49 -0
- data/lib/configdirector/internal/evaluation/served_value.rb +9 -0
- data/lib/configdirector/internal/evaluation/share.rb +9 -0
- data/lib/configdirector/internal/evaluation/targeting_rules.rb +18 -0
- data/lib/configdirector/internal/evaluation/text_comparison.rb +32 -0
- data/lib/configdirector/internal/evaluation/trait_pointer.rb +42 -0
- data/lib/configdirector/internal/evaluation.rb +21 -0
- data/lib/configdirector/internal/identity/sdk_identity.rb +39 -0
- data/lib/configdirector/internal/identity/wrapper.rb +48 -0
- data/lib/configdirector/internal/logging/client_log.rb +37 -0
- data/lib/configdirector/internal/logging/default_logger.rb +34 -0
- data/lib/configdirector/internal/polling/poll_answer.rb +111 -0
- data/lib/configdirector/internal/polling/poll_request.rb +106 -0
- data/lib/configdirector/internal/polling/poll_timing.rb +25 -0
- data/lib/configdirector/internal/polling/polling_endpoint.rb +36 -0
- data/lib/configdirector/internal/polling/polling_mode_connection.rb +53 -0
- data/lib/configdirector/internal/polling/polling_session.rb +99 -0
- data/lib/configdirector/internal/polling/polling_transport.rb +74 -0
- data/lib/configdirector/internal/polling/refusal_detail.rb +36 -0
- data/lib/configdirector/internal/server_sent_events/event_stream_limit_exceeded.rb +9 -0
- data/lib/configdirector/internal/server_sent_events/event_stream_parser.rb +95 -0
- data/lib/configdirector/internal/server_sent_events/server_sent_event.rb +9 -0
- data/lib/configdirector/internal/stoppable_thread.rb +69 -0
- data/lib/configdirector/internal/streaming/heartbeats.rb +51 -0
- data/lib/configdirector/internal/streaming/reconnecting_stream.rb +82 -0
- data/lib/configdirector/internal/streaming/reconnection_delay.rb +29 -0
- data/lib/configdirector/internal/streaming/stream_connection.rb +86 -0
- data/lib/configdirector/internal/streaming/stream_end.rb +69 -0
- data/lib/configdirector/internal/streaming/stream_endpoint.rb +43 -0
- data/lib/configdirector/internal/streaming/stream_timing.rb +33 -0
- data/lib/configdirector/internal/streaming/streaming_mode_connection.rb +60 -0
- data/lib/configdirector/internal/streaming/streaming_transport.rb +42 -0
- data/lib/configdirector/internal/telemetry/aggregated_wire_entries.rb +26 -0
- data/lib/configdirector/internal/telemetry/collected_telemetry.rb +98 -0
- data/lib/configdirector/internal/telemetry/compact_json_text.rb +64 -0
- data/lib/configdirector/internal/telemetry/discarded_telemetry.rb +31 -0
- data/lib/configdirector/internal/telemetry/event_reporter.rb +47 -0
- data/lib/configdirector/internal/telemetry/invalid_context_submissions.rb +76 -0
- data/lib/configdirector/internal/telemetry/report_answer.rb +31 -0
- data/lib/configdirector/internal/telemetry/report_schedule.rb +66 -0
- data/lib/configdirector/internal/telemetry/report_timing.rb +20 -0
- data/lib/configdirector/internal/telemetry/reported_context.rb +28 -0
- data/lib/configdirector/internal/telemetry/reported_details.rb +71 -0
- data/lib/configdirector/internal/telemetry/reported_evaluation.rb +82 -0
- data/lib/configdirector/internal/telemetry/reported_telemetry.rb +127 -0
- data/lib/configdirector/internal/telemetry/reported_text.rb +13 -0
- data/lib/configdirector/internal/telemetry/reported_time.rb +13 -0
- data/lib/configdirector/internal/telemetry/reported_value.rb +35 -0
- data/lib/configdirector/internal/telemetry/telemetry_endpoint.rb +54 -0
- data/lib/configdirector/internal/telemetry/telemetry_report.rb +50 -0
- data/lib/configdirector/internal/telemetry/test_client_telemetry.rb +37 -0
- data/lib/configdirector/internal/telemetry/tracked_event_admission.rb +72 -0
- data/lib/configdirector/internal/telemetry/tracked_event_entry.rb +27 -0
- data/lib/configdirector/internal/telemetry/tracked_event_queue.rb +47 -0
- data/lib/configdirector/internal/telemetry/tracked_event_warning.rb +28 -0
- data/lib/configdirector/internal/telemetry/value_id.rb +23 -0
- data/lib/configdirector/internal/telemetry/written_json.rb +9 -0
- data/lib/configdirector/internal/unchangeable_copy.rb +38 -0
- data/lib/configdirector/internal/value/encoded_native_value.rb +45 -0
- data/lib/configdirector/internal/value/hash_keys.rb +34 -0
- data/lib/configdirector/internal/value/in_code_default_value.rb +33 -0
- data/lib/configdirector/internal/value/json_contents.rb +81 -0
- data/lib/configdirector/internal/value/json_position.rb +27 -0
- data/lib/configdirector/internal/value/native_values.rb +41 -0
- data/lib/configdirector/internal/value/parsed_json.rb +79 -0
- data/lib/configdirector/internal/value/plain_decimal_text.rb +36 -0
- data/lib/configdirector/internal/value/served_text.rb +76 -0
- data/lib/configdirector/internal/value/typed_value.rb +9 -0
- data/lib/configdirector/internal/value/unservable_value.rb +9 -0
- data/lib/configdirector/internal/value/utf8_text.rb +19 -0
- data/lib/configdirector/internal.rb +9 -0
- data/lib/configdirector/metadata.rb +26 -0
- data/lib/configdirector/subscription.rb +34 -0
- data/lib/configdirector/telemetry_options.rb +28 -0
- data/lib/configdirector/testing/test_client.rb +122 -0
- data/lib/configdirector/testing/tracked_event.rb +46 -0
- data/lib/configdirector/testing.rb +44 -0
- data/lib/configdirector/variation.rb +21 -0
- data/lib/configdirector/version.rb +7 -0
- data/lib/configdirector-server-sdk.rb +3 -0
- data/lib/configdirector.rb +164 -0
- data/sig/configdirector/internal/client.rbs +518 -0
- data/sig/configdirector/internal/connection.rbs +389 -0
- data/sig/configdirector/internal/evaluation.rbs +364 -0
- data/sig/configdirector/internal/identity.rbs +51 -0
- data/sig/configdirector/internal/logging.rbs +33 -0
- data/sig/configdirector/internal/polling.rbs +240 -0
- data/sig/configdirector/internal/server_sent_events.rbs +51 -0
- data/sig/configdirector/internal/streaming.rbs +266 -0
- data/sig/configdirector/internal/telemetry.rbs +556 -0
- data/sig/configdirector/internal/value.rbs +159 -0
- data/sig/configdirector/testing.rbs +70 -0
- data/sig/configdirector.rbs +465 -0
- metadata +231 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
module ConfigDirector
|
|
2
|
+
module Internal
|
|
3
|
+
module UnchangeableCopy
|
|
4
|
+
MOST_LEVELS_THE_SDK_READS_OF_A_VALUE: Integer
|
|
5
|
+
|
|
6
|
+
def self.of: (untyped value) -> untyped
|
|
7
|
+
|
|
8
|
+
private def self.nested_deeper_than?: (Integer levels, untyped value) -> bool
|
|
9
|
+
|
|
10
|
+
private def self.any_nested_deeper_than?: (Integer levels, Array[untyped] contents) -> bool
|
|
11
|
+
|
|
12
|
+
private def self.copy_of: (untyped value) -> untyped
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module Client
|
|
16
|
+
module ClientOptionsValidation
|
|
17
|
+
EVENT_QUEUE_LIMITS: Range[Integer]
|
|
18
|
+
LOGGER_METHODS: Array[Symbol]
|
|
19
|
+
|
|
20
|
+
def self.reject_unusable: (
|
|
21
|
+
server_sdk_key: untyped,
|
|
22
|
+
metadata: untyped,
|
|
23
|
+
connection: untyped,
|
|
24
|
+
telemetry: untyped,
|
|
25
|
+
hooks: untyped,
|
|
26
|
+
logger: untyped
|
|
27
|
+
) -> void
|
|
28
|
+
|
|
29
|
+
private def self.reject_an_option_of_another_class: (String option_name, untyped option, Class option_class) -> void
|
|
30
|
+
|
|
31
|
+
def self.reject_an_unusable_logger: (untyped logger) -> void
|
|
32
|
+
|
|
33
|
+
private def self.reject_unusable_telemetry: (TelemetryOptions telemetry) -> void
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
module ConnectionOptionsValidation
|
|
37
|
+
SOURCE_OF_VALUES_BY_MODE: Hash[String, Symbol]
|
|
38
|
+
|
|
39
|
+
def self.reject_unusable: (ConnectionOptions connection, untyped server_sdk_key) -> void
|
|
40
|
+
|
|
41
|
+
private def self.reject_an_unknown_mode: (untyped mode) -> void
|
|
42
|
+
|
|
43
|
+
private def self.reject_an_unusable_connection_to_configdirector: (
|
|
44
|
+
ConnectionOptions connection,
|
|
45
|
+
untyped server_sdk_key
|
|
46
|
+
) -> void
|
|
47
|
+
|
|
48
|
+
def self.reject_a_timeout_that_is_not_positive: (untyped timeout) -> void
|
|
49
|
+
|
|
50
|
+
private def self.reject_an_offline_timeout_that_is_not_a_number: (untyped timeout) -> void
|
|
51
|
+
|
|
52
|
+
private def self.reject_an_unusable_server_sdk_key: (untyped server_sdk_key) -> void
|
|
53
|
+
|
|
54
|
+
private def self.reject_offline_values_given_to: (ConnectionOptions connection) -> void
|
|
55
|
+
|
|
56
|
+
private def self.reject_an_unusable_url: (untyped url) -> void
|
|
57
|
+
|
|
58
|
+
private def self.http_url?: (untyped url) -> bool
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
module NumberOfSeconds
|
|
62
|
+
def self.finite?: (untyped value) -> bool
|
|
63
|
+
|
|
64
|
+
def self.finite_and_positive?: (untyped value) -> bool
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
module ContextAttributes
|
|
68
|
+
MOST_LEVELS_OF_TRAITS: Integer
|
|
69
|
+
|
|
70
|
+
def self.identifier_text: (untyped id) -> String?
|
|
71
|
+
|
|
72
|
+
def self.name_text: (untyped name) -> String?
|
|
73
|
+
|
|
74
|
+
def self.traits_with_symbols_as_text: (untyped traits) -> Hash[String, untyped]?
|
|
75
|
+
|
|
76
|
+
def self.anonymous_flag: (untyped anonymous) -> bool
|
|
77
|
+
|
|
78
|
+
private def self.with_symbols_as_text: (untyped trait, Integer level) -> untyped
|
|
79
|
+
|
|
80
|
+
private def self.container_with_symbols_as_text: (Hash[untyped, untyped] | Array[untyped] container, Integer level) -> untyped
|
|
81
|
+
|
|
82
|
+
private def self.traits_nested_too_deep: () -> ConfigDirectorValidationError
|
|
83
|
+
|
|
84
|
+
private def self.text_of_a_symbol: (untyped key_or_value) -> untyped
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
module ContextKind
|
|
88
|
+
VALID_KIND: Regexp
|
|
89
|
+
SAMPLE_MAXIMUM_CHARACTERS: Integer
|
|
90
|
+
|
|
91
|
+
def self.valid?: (untyped kind) -> bool
|
|
92
|
+
|
|
93
|
+
def self.sample_of: (untyped kind) -> String
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class ContextAdmission
|
|
97
|
+
LOG_AN_INVALID_KIND: Hash[Symbol, ^(Logging::ClientLog log, String kind_sample) -> void]
|
|
98
|
+
|
|
99
|
+
@log: Logging::ClientLog
|
|
100
|
+
@telemetry: Telemetry::_ClientTelemetry
|
|
101
|
+
|
|
102
|
+
def initialize: (Logging::ClientLog log, Telemetry::_ClientTelemetry telemetry) -> void
|
|
103
|
+
|
|
104
|
+
def admitted_context_or_none: (untyped context) -> Context?
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class ConfigRead < Data
|
|
108
|
+
attr_reader config_key: String
|
|
109
|
+
attr_reader in_code_default_value: Value::InCodeDefaultValue
|
|
110
|
+
attr_reader context: Context?
|
|
111
|
+
|
|
112
|
+
def self.new: (
|
|
113
|
+
config_key: String,
|
|
114
|
+
in_code_default_value: Value::InCodeDefaultValue,
|
|
115
|
+
context: Context?
|
|
116
|
+
) -> instance
|
|
117
|
+
|
|
118
|
+
def evaluated_to_the_in_code_default_value: (String reason, ConfigState? config_state) -> EvaluatedRead
|
|
119
|
+
|
|
120
|
+
def evaluated_to: (Value::TypedValue typed_value, ConfigState config_state, String reason) -> EvaluatedRead
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
class EvaluatedRead < Data
|
|
124
|
+
attr_reader config_read: ConfigRead
|
|
125
|
+
attr_reader evaluation: ConfigEvaluation[config_value]
|
|
126
|
+
attr_reader config_state: ConfigState?
|
|
127
|
+
|
|
128
|
+
def self.new: (config_read: ConfigRead, evaluation: ConfigEvaluation[config_value], config_state: ConfigState?) -> instance
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
type arrival_of_values = :after_close | :first_values | :newer_values
|
|
132
|
+
|
|
133
|
+
class EventTracking
|
|
134
|
+
TRACKS_EVENTS_BY_MODE: Hash[String, bool]
|
|
135
|
+
|
|
136
|
+
@tracks_events: bool
|
|
137
|
+
@telemetry: Telemetry::_ClientTelemetry
|
|
138
|
+
@log: Logging::ClientLog
|
|
139
|
+
@context_admission: ContextAdmission
|
|
140
|
+
|
|
141
|
+
def initialize: (mode: String, telemetry: Telemetry::_ClientTelemetry, log: Logging::ClientLog) -> void
|
|
142
|
+
|
|
143
|
+
def track: (untyped event_name, untyped context, value: untyped, details: untyped) -> nil
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
class ConfigReader
|
|
147
|
+
@serving_state: ServingState
|
|
148
|
+
@event_handlers: EventHandlers
|
|
149
|
+
@telemetry: Telemetry::_ClientTelemetry
|
|
150
|
+
@log: Logging::ClientLog
|
|
151
|
+
@context_admission: ContextAdmission
|
|
152
|
+
|
|
153
|
+
def initialize: (
|
|
154
|
+
serving_state: ServingState,
|
|
155
|
+
event_handlers: EventHandlers,
|
|
156
|
+
telemetry: Telemetry::_ClientTelemetry,
|
|
157
|
+
log: Logging::ClientLog
|
|
158
|
+
) -> void
|
|
159
|
+
|
|
160
|
+
def config_read_of: (untyped config_key, untyped default_value, untyped context) -> ConfigRead
|
|
161
|
+
|
|
162
|
+
def evaluation_of: (
|
|
163
|
+
String config_key,
|
|
164
|
+
config_value default_value,
|
|
165
|
+
Context? context
|
|
166
|
+
) -> ConfigEvaluation[untyped]
|
|
167
|
+
|
|
168
|
+
def read: (ConfigRead config_read) -> ConfigEvaluation[config_value]
|
|
169
|
+
|
|
170
|
+
def states: (untyped context, untyped config_keys) -> Hash[String, ConfigState]
|
|
171
|
+
|
|
172
|
+
private
|
|
173
|
+
|
|
174
|
+
def reject_config_keys_that_are_not_an_array: (untyped config_keys) -> void
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
class Registrations[T < Object]
|
|
178
|
+
@lock: Thread::Mutex
|
|
179
|
+
@registrations_by_topic: Hash[untyped, Array[T]]
|
|
180
|
+
|
|
181
|
+
def initialize: () -> void
|
|
182
|
+
|
|
183
|
+
def add: (untyped topic, T registration) -> Subscription
|
|
184
|
+
|
|
185
|
+
def remove_first: (untyped topic) { (T registration) -> boolish } -> nil
|
|
186
|
+
|
|
187
|
+
def remove_all_on: (untyped topic) -> nil
|
|
188
|
+
|
|
189
|
+
def remove_all: () -> nil
|
|
190
|
+
|
|
191
|
+
def on: (Array[untyped] topics) -> Array[T]
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
class EventHandlers
|
|
195
|
+
class HandlerRegistration < Data
|
|
196
|
+
attr_reader handler: _EventHandler & Object
|
|
197
|
+
|
|
198
|
+
def self.new: (handler: _EventHandler & Object) -> instance
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
HOOKS_BY_EVENT_NAME: Hash[Symbol, ^(ClientHooks hooks) -> untyped]
|
|
202
|
+
|
|
203
|
+
@log: Logging::ClientLog
|
|
204
|
+
@registrations: Registrations[HandlerRegistration]
|
|
205
|
+
|
|
206
|
+
def self.one_handler_of: (untyped handler, Proc? block) -> untyped
|
|
207
|
+
|
|
208
|
+
def initialize: (ClientHooks hooks, Logging::ClientLog log) -> void
|
|
209
|
+
|
|
210
|
+
def add: (untyped event_name, _EventHandler & Object handler) -> Subscription
|
|
211
|
+
|
|
212
|
+
def remove: (untyped event_name, untyped handler) -> nil
|
|
213
|
+
|
|
214
|
+
def remove_all: () -> nil
|
|
215
|
+
|
|
216
|
+
def deliver_client_ready: () -> void
|
|
217
|
+
|
|
218
|
+
def deliver_configs_updated: (ConfigsUpdatedEvent update) -> void
|
|
219
|
+
|
|
220
|
+
def deliver_config_evaluated: (ConfigEvaluation[config_value] evaluation) -> void
|
|
221
|
+
|
|
222
|
+
def deliver_connection_error: (ConfigDirectorConnectionError error) -> void
|
|
223
|
+
|
|
224
|
+
private
|
|
225
|
+
|
|
226
|
+
def reject_an_unknown_event_name: (untyped event_name) -> void
|
|
227
|
+
|
|
228
|
+
def register: (Symbol event_name, _EventHandler & Object handler) -> Subscription
|
|
229
|
+
|
|
230
|
+
def register_the_hooks_in: (ClientHooks hooks) -> void
|
|
231
|
+
|
|
232
|
+
def register_a_hook: (Symbol event_name, untyped handler) -> void
|
|
233
|
+
|
|
234
|
+
def handlers_given: (untyped hooks_of_the_event) -> Array[untyped]
|
|
235
|
+
|
|
236
|
+
def deliver: (Symbol event_name, *untyped arguments) -> void
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
class Watches
|
|
240
|
+
class Watch < Data
|
|
241
|
+
attr_reader config_read: ConfigRead
|
|
242
|
+
attr_reader callback: Proc
|
|
243
|
+
|
|
244
|
+
def self.new: (config_read: ConfigRead, callback: Proc) -> instance
|
|
245
|
+
|
|
246
|
+
def config_key: () -> String
|
|
247
|
+
|
|
248
|
+
def receive: (config_value value) -> void
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
@log: Logging::ClientLog
|
|
252
|
+
@registrations: Registrations[Watch]
|
|
253
|
+
|
|
254
|
+
def initialize: (Logging::ClientLog log) -> void
|
|
255
|
+
|
|
256
|
+
def add: (ConfigRead config_read, Proc callback) -> Subscription
|
|
257
|
+
|
|
258
|
+
def remove: (untyped config_key, untyped callback) -> nil
|
|
259
|
+
|
|
260
|
+
def remove_all: () -> nil
|
|
261
|
+
|
|
262
|
+
def deliver_on: (Array[String] config_keys) { (ConfigRead config_read) -> config_value } -> void
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
module ClientFactory
|
|
266
|
+
CONNECTION_CLASS_BY_MODE: Hash[String, Connection::_ConnectionOfAMode]
|
|
267
|
+
TELEMETRY_CLASS_BY_MODE: Hash[String, Telemetry::_TelemetryOfAMode]
|
|
268
|
+
|
|
269
|
+
def self.client_identified_as: (
|
|
270
|
+
Identity::SdkIdentity sdk_identity,
|
|
271
|
+
String? server_sdk_key,
|
|
272
|
+
metadata: Metadata?,
|
|
273
|
+
connection: ConnectionOptions?,
|
|
274
|
+
logger: (_Logger & Object)?,
|
|
275
|
+
log_level: (Integer | Symbol | String)?,
|
|
276
|
+
telemetry: TelemetryOptions?,
|
|
277
|
+
hooks: ClientHooks?
|
|
278
|
+
) -> ConfigDirectorClient
|
|
279
|
+
|
|
280
|
+
def self.test_client_serving: (
|
|
281
|
+
untyped values,
|
|
282
|
+
timeout: untyped,
|
|
283
|
+
logger: (_Logger & Object)?
|
|
284
|
+
) -> Testing::TestClient
|
|
285
|
+
|
|
286
|
+
private def self.client_with_usable_options: (
|
|
287
|
+
sdk_identity: Identity::SdkIdentity,
|
|
288
|
+
server_sdk_key: String,
|
|
289
|
+
metadata: Metadata,
|
|
290
|
+
connection_options: ConnectionOptions,
|
|
291
|
+
telemetry_options: TelemetryOptions,
|
|
292
|
+
logger: _Logger & Object,
|
|
293
|
+
hooks: ClientHooks
|
|
294
|
+
) -> ConfigDirectorClient
|
|
295
|
+
|
|
296
|
+
private def self.options_or_their_defaults: (
|
|
297
|
+
Metadata? metadata,
|
|
298
|
+
ConnectionOptions? connection,
|
|
299
|
+
TelemetryOptions? telemetry,
|
|
300
|
+
ClientHooks? hooks
|
|
301
|
+
) -> [Metadata, ConnectionOptions, TelemetryOptions, ClientHooks]
|
|
302
|
+
|
|
303
|
+
private def self.client_over: (
|
|
304
|
+
Connection::_Connection connection,
|
|
305
|
+
Telemetry::_ClientTelemetry telemetry,
|
|
306
|
+
ConnectionOptions connection_options,
|
|
307
|
+
metadata: Metadata,
|
|
308
|
+
logger: _Logger & Object,
|
|
309
|
+
hooks: ClientHooks
|
|
310
|
+
) -> ConfigDirectorClient
|
|
311
|
+
|
|
312
|
+
private def self.client_over_an_in_memory_connection: (
|
|
313
|
+
Connection::InMemoryConnection connection,
|
|
314
|
+
Telemetry::TestClientTelemetry telemetry,
|
|
315
|
+
seconds timeout,
|
|
316
|
+
_Logger & Object logger
|
|
317
|
+
) -> ConfigDirectorClient
|
|
318
|
+
|
|
319
|
+
private def self.warn_of_a_polling_interval_below_the_minimum: (
|
|
320
|
+
ConnectionOptions connection,
|
|
321
|
+
_Logger & Object logger
|
|
322
|
+
) -> void
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
class ConnectionIntake
|
|
326
|
+
@serving_state: ServingState
|
|
327
|
+
@event_handlers: EventHandlers
|
|
328
|
+
@watches: Watches
|
|
329
|
+
@config_reader: ConfigReader
|
|
330
|
+
@log: Logging::ClientLog
|
|
331
|
+
|
|
332
|
+
def initialize: (
|
|
333
|
+
serving_state: ServingState,
|
|
334
|
+
event_handlers: EventHandlers,
|
|
335
|
+
watches: Watches,
|
|
336
|
+
config_reader: ConfigReader,
|
|
337
|
+
log: Logging::ClientLog
|
|
338
|
+
) -> void
|
|
339
|
+
|
|
340
|
+
def take_in: (Connection::ServerSdkPayload payload) -> void
|
|
341
|
+
|
|
342
|
+
def take_in_unrecoverable_error: (ConfigDirectorConnectionError connection_error) -> void
|
|
343
|
+
|
|
344
|
+
private
|
|
345
|
+
|
|
346
|
+
def warn_of_the_definitions_skipped_in: (Connection::ServerSdkPayload payload) -> void
|
|
347
|
+
|
|
348
|
+
def deliver_the_first_values: (ConfigsUpdatedEvent update) -> void
|
|
349
|
+
|
|
350
|
+
def deliver_the_update: (ConfigsUpdatedEvent update) -> void
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
module WhatFollowsAFork
|
|
354
|
+
WHAT_FOLLOWS_A_FORK_BY_MODE: Hash[String, Symbol]
|
|
355
|
+
|
|
356
|
+
def self.for_a_client_with: (
|
|
357
|
+
mode: String,
|
|
358
|
+
connection_opened: bool,
|
|
359
|
+
closed: bool,
|
|
360
|
+
connection_failed_unrecoverably: bool
|
|
361
|
+
) -> Symbol
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
interface _ProcessThatCanFork
|
|
365
|
+
def _fork: () -> Integer
|
|
366
|
+
|
|
367
|
+
def daemon: (*untyped) -> Integer
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
module RestartInForkedProcesses : _ProcessThatCanFork
|
|
371
|
+
def _fork: () -> Integer
|
|
372
|
+
|
|
373
|
+
def daemon: (*untyped) -> Integer
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
class LiveClientConnections
|
|
377
|
+
OF_THE_PROCESS: LiveClientConnections
|
|
378
|
+
|
|
379
|
+
@lock: Thread::Mutex
|
|
380
|
+
@client_connections: Array[ClientConnection]
|
|
381
|
+
|
|
382
|
+
def initialize: () -> void
|
|
383
|
+
|
|
384
|
+
def add: (ClientConnection client_connection) -> nil
|
|
385
|
+
|
|
386
|
+
def remove: (ClientConnection client_connection) -> nil
|
|
387
|
+
|
|
388
|
+
def restart_in_a_forked_process: (Symbol forked_through) -> nil
|
|
389
|
+
|
|
390
|
+
private
|
|
391
|
+
|
|
392
|
+
def without: (ClientConnection client_connection) -> Array[ClientConnection]
|
|
393
|
+
|
|
394
|
+
def restart_each_on_a_thread_of_the_forked_process: (Array[ClientConnection] client_connections) -> nil
|
|
395
|
+
|
|
396
|
+
def restart_each_in_a_forked_process: (Array[ClientConnection] client_connections) -> nil
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
class ClientConnection
|
|
400
|
+
CONNECTION_AT_A_LATER_INIT_BY_MODE: Hash[String, Symbol]
|
|
401
|
+
WHAT_FOLLOWS_AN_INIT_WITHOUT_VALUES_BY_MODE: Hash[String, String]
|
|
402
|
+
|
|
403
|
+
@connection: Connection::_Connection
|
|
404
|
+
@telemetry: Telemetry::_ClientTelemetry
|
|
405
|
+
@mode: String
|
|
406
|
+
@lifecycle: Monitor
|
|
407
|
+
@connection_opened: bool
|
|
408
|
+
@serving_state: ServingState
|
|
409
|
+
@log: Logging::ClientLog
|
|
410
|
+
@report_unrecoverable_error: ^(ConfigDirectorConnectionError unrecoverable_error) -> void
|
|
411
|
+
@deliver_payload: ^(Connection::ServerSdkPayload payload) -> void
|
|
412
|
+
|
|
413
|
+
def initialize: (
|
|
414
|
+
connection: Connection::_Connection,
|
|
415
|
+
telemetry: Telemetry::_ClientTelemetry,
|
|
416
|
+
mode: String,
|
|
417
|
+
serving_state: ServingState,
|
|
418
|
+
intake: ConnectionIntake,
|
|
419
|
+
log: Logging::ClientLog,
|
|
420
|
+
lifecycle: Monitor
|
|
421
|
+
) -> void
|
|
422
|
+
|
|
423
|
+
def open: () -> Symbol?
|
|
424
|
+
|
|
425
|
+
def close: () -> void
|
|
426
|
+
|
|
427
|
+
def warn_that_no_values_arrived_within: (seconds timeout) -> void
|
|
428
|
+
|
|
429
|
+
def choose_the_reporter_of_what_the_parent_process_collected: (Symbol forked_through) -> void
|
|
430
|
+
|
|
431
|
+
def restart_in_a_forked_process: () -> void
|
|
432
|
+
|
|
433
|
+
private
|
|
434
|
+
|
|
435
|
+
def connection_at_this_init: () -> Symbol
|
|
436
|
+
|
|
437
|
+
def open_the_connection: () -> Symbol
|
|
438
|
+
|
|
439
|
+
def what_follows_a_fork: (connection_opened: bool) -> Symbol
|
|
440
|
+
|
|
441
|
+
def restart_the_telemetry_and_the_connection: () -> void
|
|
442
|
+
|
|
443
|
+
def restart_the_telemetry: () -> void
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
class ServingState
|
|
447
|
+
@metadata: Metadata
|
|
448
|
+
@lock: Thread::Mutex
|
|
449
|
+
@first_values_no_longer_awaited: Thread::ConditionVariable
|
|
450
|
+
@served_configs: ServedConfigs?
|
|
451
|
+
@thread_delivering_the_first_values: Thread?
|
|
452
|
+
@first_values_delivered: bool
|
|
453
|
+
@closed: bool
|
|
454
|
+
@connection_failed_unrecoverably: bool
|
|
455
|
+
|
|
456
|
+
def initialize: (Metadata metadata) -> void
|
|
457
|
+
|
|
458
|
+
def served_configs: () -> ServedConfigs?
|
|
459
|
+
|
|
460
|
+
def closed?: () -> bool
|
|
461
|
+
|
|
462
|
+
def connection_failed_unrecoverably?: () -> bool
|
|
463
|
+
|
|
464
|
+
def serve: (Connection::ServerSdkPayload payload) -> [arrival_of_values, ConfigsUpdatedEvent]
|
|
465
|
+
|
|
466
|
+
def end_the_delivery_of_the_first_values: () -> void
|
|
467
|
+
|
|
468
|
+
def close: () -> void
|
|
469
|
+
|
|
470
|
+
def expect_values_from_the_connection: () -> void
|
|
471
|
+
|
|
472
|
+
def expect_no_values_from_the_connection: () -> void
|
|
473
|
+
|
|
474
|
+
def leave_the_delivery_of_the_first_values_to_the_parent_process: () -> void
|
|
475
|
+
|
|
476
|
+
def timed_out_waiting_for_the_first_values?: (Float give_up_at_monotonic_seconds) -> bool
|
|
477
|
+
|
|
478
|
+
private
|
|
479
|
+
|
|
480
|
+
def arrival_of_values: () -> arrival_of_values
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
class ServedConfigs < Data
|
|
484
|
+
REASON_BY_SERVED_BY: Hash[Symbol, String]
|
|
485
|
+
|
|
486
|
+
attr_reader configs: Hash[String, Connection::ConfigDefinition]
|
|
487
|
+
attr_reader segments: Evaluation::segments
|
|
488
|
+
attr_reader metadata: Metadata
|
|
489
|
+
|
|
490
|
+
def self.new: (
|
|
491
|
+
configs: Hash[String, Connection::ConfigDefinition],
|
|
492
|
+
segments: Evaluation::segments,
|
|
493
|
+
metadata: Metadata
|
|
494
|
+
) -> instance
|
|
495
|
+
|
|
496
|
+
def self.without_definitions: (Metadata metadata) -> ServedConfigs
|
|
497
|
+
|
|
498
|
+
def after: (Connection::ServerSdkPayload payload) -> ServedConfigs
|
|
499
|
+
|
|
500
|
+
def update_since: (ServedConfigs replaced_configs, Connection::ServerSdkPayload payload) -> ConfigsUpdatedEvent
|
|
501
|
+
|
|
502
|
+
def evaluated_read: (ConfigRead config_read) -> EvaluatedRead
|
|
503
|
+
|
|
504
|
+
def states: (Context? context, Array[String]? config_keys) -> Hash[String, ConfigState]
|
|
505
|
+
|
|
506
|
+
private
|
|
507
|
+
|
|
508
|
+
def keys_of_configs_using_any_segment_of: (Array[String] segment_ids) -> Array[String]
|
|
509
|
+
|
|
510
|
+
def evaluated_read_of: (Connection::ConfigDefinition definition, ConfigRead config_read) -> EvaluatedRead
|
|
511
|
+
|
|
512
|
+
def value_served_to: (Context? context, Connection::ConfigDefinition definition) -> Evaluation::ServedValue
|
|
513
|
+
|
|
514
|
+
def evaluation_context_of: (Context? context) -> Evaluation::EvaluationContext
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
end
|
|
518
|
+
end
|