launchdarkly-server-sdk 8.11.2-java → 8.12.0-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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ldclient-rb/config.rb +69 -9
  3. data/lib/ldclient-rb/context.rb +1 -1
  4. data/lib/ldclient-rb/data_system.rb +227 -0
  5. data/lib/ldclient-rb/events.rb +34 -19
  6. data/lib/ldclient-rb/flags_state.rb +1 -1
  7. data/lib/ldclient-rb/impl/big_segments.rb +4 -4
  8. data/lib/ldclient-rb/impl/cache_store.rb +44 -0
  9. data/lib/ldclient-rb/impl/data_source/polling.rb +108 -0
  10. data/lib/ldclient-rb/impl/data_source/requestor.rb +113 -0
  11. data/lib/ldclient-rb/impl/data_source/status_provider.rb +83 -0
  12. data/lib/ldclient-rb/impl/data_source/stream.rb +198 -0
  13. data/lib/ldclient-rb/impl/data_source.rb +3 -3
  14. data/lib/ldclient-rb/impl/data_store/data_kind.rb +108 -0
  15. data/lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb +187 -0
  16. data/lib/ldclient-rb/impl/data_store/in_memory_feature_store.rb +130 -0
  17. data/lib/ldclient-rb/impl/data_store/status_provider.rb +76 -0
  18. data/lib/ldclient-rb/impl/data_store/store.rb +371 -0
  19. data/lib/ldclient-rb/impl/data_store.rb +11 -97
  20. data/lib/ldclient-rb/impl/data_system/data_source_builder_common.rb +77 -0
  21. data/lib/ldclient-rb/impl/data_system/fdv1.rb +20 -7
  22. data/lib/ldclient-rb/impl/data_system/fdv2.rb +472 -0
  23. data/lib/ldclient-rb/impl/data_system/http_config_options.rb +32 -0
  24. data/lib/ldclient-rb/impl/data_system/polling.rb +628 -0
  25. data/lib/ldclient-rb/impl/data_system/protocolv2.rb +264 -0
  26. data/lib/ldclient-rb/impl/data_system/streaming.rb +401 -0
  27. data/lib/ldclient-rb/impl/dependency_tracker.rb +21 -9
  28. data/lib/ldclient-rb/impl/evaluator.rb +3 -2
  29. data/lib/ldclient-rb/impl/event_sender.rb +14 -6
  30. data/lib/ldclient-rb/impl/expiring_cache.rb +79 -0
  31. data/lib/ldclient-rb/impl/integrations/file_data_source.rb +8 -8
  32. data/lib/ldclient-rb/impl/integrations/file_data_source_v2.rb +460 -0
  33. data/lib/ldclient-rb/impl/integrations/test_data/test_data_source_v2.rb +290 -0
  34. data/lib/ldclient-rb/impl/memoized_value.rb +34 -0
  35. data/lib/ldclient-rb/impl/migrations/migrator.rb +2 -1
  36. data/lib/ldclient-rb/impl/migrations/tracker.rb +2 -1
  37. data/lib/ldclient-rb/impl/model/serialization.rb +6 -6
  38. data/lib/ldclient-rb/impl/non_blocking_thread_pool.rb +48 -0
  39. data/lib/ldclient-rb/impl/repeating_task.rb +2 -2
  40. data/lib/ldclient-rb/impl/simple_lru_cache.rb +27 -0
  41. data/lib/ldclient-rb/impl/store_data_set_sorter.rb +1 -1
  42. data/lib/ldclient-rb/impl/util.rb +71 -0
  43. data/lib/ldclient-rb/impl.rb +1 -2
  44. data/lib/ldclient-rb/in_memory_store.rb +1 -18
  45. data/lib/ldclient-rb/integrations/file_data.rb +67 -0
  46. data/lib/ldclient-rb/integrations/test_data/flag_builder.rb +9 -9
  47. data/lib/ldclient-rb/integrations/test_data.rb +11 -11
  48. data/lib/ldclient-rb/integrations/test_data_v2/flag_builder_v2.rb +582 -0
  49. data/lib/ldclient-rb/integrations/test_data_v2.rb +254 -0
  50. data/lib/ldclient-rb/integrations/util/store_wrapper.rb +3 -2
  51. data/lib/ldclient-rb/interfaces/data_system.rb +704 -0
  52. data/lib/ldclient-rb/interfaces/feature_store.rb +5 -2
  53. data/lib/ldclient-rb/ldclient.rb +66 -132
  54. data/lib/ldclient-rb/util.rb +11 -70
  55. data/lib/ldclient-rb/version.rb +1 -1
  56. data/lib/ldclient-rb.rb +9 -17
  57. metadata +41 -19
  58. data/lib/ldclient-rb/cache_store.rb +0 -45
  59. data/lib/ldclient-rb/expiring_cache.rb +0 -77
  60. data/lib/ldclient-rb/memoized_value.rb +0 -32
  61. data/lib/ldclient-rb/non_blocking_thread_pool.rb +0 -46
  62. data/lib/ldclient-rb/polling.rb +0 -102
  63. data/lib/ldclient-rb/requestor.rb +0 -102
  64. data/lib/ldclient-rb/simple_lru_cache.rb +0 -25
  65. data/lib/ldclient-rb/stream.rb +0 -197
@@ -0,0 +1,704 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LaunchDarkly
4
+ module Interfaces
5
+ module DataSystem
6
+ #
7
+ # EventName represents the name of an event that can be sent by the server for FDv2.
8
+ #
9
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
10
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
11
+ #
12
+ module EventName
13
+ # Specifies that an object should be added to the data set with upsert semantics.
14
+ PUT_OBJECT = :"put-object"
15
+
16
+ # Specifies that an object should be removed from the data set.
17
+ DELETE_OBJECT = :"delete-object"
18
+
19
+ # Specifies the server's intent.
20
+ SERVER_INTENT = :"server-intent"
21
+
22
+ # Specifies that all data required to bring the existing data set to a new version has been transferred.
23
+ PAYLOAD_TRANSFERRED = :"payload-transferred"
24
+
25
+ # Keeps the connection alive.
26
+ HEARTBEAT = :"heart-beat"
27
+
28
+ # Specifies that the server is about to close the connection.
29
+ GOODBYE = :goodbye
30
+
31
+ # Specifies that an error occurred while serving the connection.
32
+ ERROR = :error
33
+ end
34
+
35
+ #
36
+ # ObjectKind represents the kind of object.
37
+ #
38
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
39
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
40
+ #
41
+ module ObjectKind
42
+ # Represents a feature flag.
43
+ FLAG = "flag"
44
+
45
+ # Represents a segment.
46
+ SEGMENT = "segment"
47
+ end
48
+
49
+ #
50
+ # ChangeType specifies if an object is being upserted or deleted.
51
+ #
52
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
53
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
54
+ #
55
+ module ChangeType
56
+ # Represents an object being upserted.
57
+ PUT = "put"
58
+
59
+ # Represents an object being deleted.
60
+ DELETE = "delete"
61
+ end
62
+
63
+ #
64
+ # IntentCode represents the various intents that can be sent by the server.
65
+ #
66
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
67
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
68
+ #
69
+ module IntentCode
70
+ # The server intends to send a full data set.
71
+ TRANSFER_FULL = "xfer-full"
72
+
73
+ # The server intends to send only the necessary changes to bring an existing data set up-to-date.
74
+ TRANSFER_CHANGES = "xfer-changes"
75
+
76
+ # The server intends to send no data (payload is up to date).
77
+ TRANSFER_NONE = "none"
78
+ end
79
+
80
+ #
81
+ # DataStoreMode represents the mode of operation of a Data Store in FDV2 mode.
82
+ #
83
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
84
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
85
+ #
86
+ module DataStoreMode
87
+ # Indicates that the data store is read-only. Data will never be written back to the store by the SDK.
88
+ READ_ONLY = :read_only
89
+
90
+ # Indicates that the data store is read-write. Data from initializers/synchronizers may be written
91
+ # to the store as necessary.
92
+ READ_WRITE = :read_write
93
+ end
94
+
95
+ #
96
+ # Selector represents a particular snapshot of data.
97
+ #
98
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
99
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
100
+ #
101
+ class Selector
102
+ # @return [String] The state
103
+ attr_reader :state
104
+
105
+ # @return [Integer] The version
106
+ attr_reader :version
107
+
108
+ #
109
+ # @param state [String] The state
110
+ # @param version [Integer] The version
111
+ #
112
+ def initialize(state: "", version: 0)
113
+ @state = state
114
+ @version = version
115
+ end
116
+
117
+ #
118
+ # Returns an empty Selector.
119
+ #
120
+ # @return [Selector]
121
+ #
122
+ def self.no_selector
123
+ Selector.new
124
+ end
125
+
126
+ #
127
+ # Returns true if the Selector has a value.
128
+ #
129
+ # @return [Boolean]
130
+ #
131
+ def defined?
132
+ self != Selector.no_selector
133
+ end
134
+
135
+ #
136
+ # Returns the event name for payload transfer.
137
+ #
138
+ # @return [Symbol]
139
+ #
140
+ def name
141
+ EventName::PAYLOAD_TRANSFERRED
142
+ end
143
+
144
+ #
145
+ # Creates a new Selector from a state string and version.
146
+ #
147
+ # @param state [String] The state
148
+ # @param version [Integer] The version
149
+ # @return [Selector]
150
+ #
151
+ def self.new_selector(state, version)
152
+ Selector.new(state: state, version: version)
153
+ end
154
+
155
+ #
156
+ # Serializes the Selector to a Hash.
157
+ #
158
+ # @return [Hash]
159
+ #
160
+ def to_h
161
+ {
162
+ state: @state,
163
+ version: @version,
164
+ }
165
+ end
166
+
167
+ #
168
+ # Deserializes a Selector from a Hash.
169
+ #
170
+ # @param data [Hash] The hash representation
171
+ # @return [Selector]
172
+ # @raise [ArgumentError] if required fields are missing
173
+ #
174
+ def self.from_h(data)
175
+ state = data['state'] || data[:state]
176
+ version = data['version'] || data[:version]
177
+
178
+ raise ArgumentError, "Missing required fields in Selector" if state.nil? || version.nil?
179
+
180
+ Selector.new(state: state, version: version)
181
+ end
182
+
183
+ def ==(other)
184
+ other.is_a?(Selector) && @state == other.state && @version == other.version
185
+ end
186
+
187
+ def eql?(other)
188
+ self == other
189
+ end
190
+
191
+ def hash
192
+ [@state, @version].hash
193
+ end
194
+ end
195
+
196
+ #
197
+ # Change represents a change to a piece of data, such as an update or deletion.
198
+ #
199
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
200
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
201
+ #
202
+ class Change
203
+ # @return [String] The action ({ChangeType})
204
+ attr_reader :action
205
+
206
+ # @return [String] The kind ({ObjectKind})
207
+ attr_reader :kind
208
+
209
+ # @return [Symbol] The key
210
+ attr_reader :key
211
+
212
+ # @return [Integer] The version
213
+ attr_reader :version
214
+
215
+ # @return [Hash, nil] The object data (for PUT actions)
216
+ attr_reader :object
217
+
218
+ #
219
+ # @param action [String] The action type ({ChangeType})
220
+ # @param kind [String] The object kind ({ObjectKind})
221
+ # @param key [Symbol] The key
222
+ # @param version [Integer] The version
223
+ # @param object [Hash, nil] The object data
224
+ #
225
+ def initialize(action:, kind:, key:, version:, object: nil)
226
+ @action = action
227
+ @kind = kind
228
+ @key = key
229
+ @version = version
230
+ @object = object
231
+ end
232
+ end
233
+
234
+ #
235
+ # ChangeSet represents a list of changes to be applied.
236
+ #
237
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
238
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
239
+ #
240
+ class ChangeSet
241
+ # @return [String] The intent code ({IntentCode})
242
+ attr_reader :intent_code
243
+
244
+ # @return [Array<Change>] The changes
245
+ attr_reader :changes
246
+
247
+ # @return [Selector, nil] The selector
248
+ attr_reader :selector
249
+
250
+ #
251
+ # @param intent_code [String] The intent code ({IntentCode})
252
+ # @param changes [Array<Change>] The changes
253
+ # @param selector [Selector, nil] The selector
254
+ #
255
+ def initialize(intent_code:, changes:, selector:)
256
+ @intent_code = intent_code
257
+ @changes = changes
258
+ @selector = selector
259
+ end
260
+ end
261
+
262
+ #
263
+ # Basis represents the initial payload of data that a data source can provide.
264
+ #
265
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
266
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
267
+ #
268
+ class Basis
269
+ # @return [ChangeSet] The change set
270
+ attr_reader :change_set
271
+
272
+ # @return [Boolean] Whether to persist
273
+ attr_reader :persist
274
+
275
+ # @return [String, nil] The environment ID
276
+ attr_reader :environment_id
277
+
278
+ #
279
+ # @param change_set [ChangeSet] The change set
280
+ # @param persist [Boolean] Whether to persist
281
+ # @param environment_id [String, nil] The environment ID
282
+ #
283
+ def initialize(change_set:, persist:, environment_id: nil)
284
+ @change_set = change_set
285
+ @persist = persist
286
+ @environment_id = environment_id
287
+ end
288
+ end
289
+
290
+ #
291
+ # Payload represents a payload delivered in a streaming response.
292
+ #
293
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
294
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
295
+ #
296
+ class Payload
297
+ # @return [String] The payload ID
298
+ attr_reader :id
299
+
300
+ # @return [Integer] The target
301
+ attr_reader :target
302
+
303
+ # @return [String] The intent code ({IntentCode})
304
+ attr_reader :code
305
+
306
+ # @return [String] The reason
307
+ attr_reader :reason
308
+
309
+ #
310
+ # @param id [String] The payload ID
311
+ # @param target [Integer] The target
312
+ # @param code [String] The intent code ({IntentCode})
313
+ # @param reason [String] The reason
314
+ #
315
+ def initialize(id:, target:, code:, reason:)
316
+ @id = id
317
+ @target = target
318
+ @code = code
319
+ @reason = reason
320
+ end
321
+
322
+ #
323
+ # Serializes the Payload to a Hash.
324
+ #
325
+ # @return [Hash]
326
+ #
327
+ def to_h
328
+ {
329
+ id: @id,
330
+ target: @target,
331
+ intentCode: @code,
332
+ reason: @reason,
333
+ }
334
+ end
335
+
336
+ #
337
+ # Deserializes a Payload from a Hash.
338
+ #
339
+ # @param data [Hash] The hash representation
340
+ # @return [Payload]
341
+ # @raise [ArgumentError] if required fields are missing or invalid
342
+ #
343
+ def self.from_h(data)
344
+ intent_code = data['intentCode'] || data[:intentCode]
345
+
346
+ raise ArgumentError, "Invalid data for Payload: 'intentCode' key is missing or not a string" if intent_code.nil? || !intent_code.is_a?(String)
347
+
348
+ Payload.new(
349
+ id: data['id'] || data[:id] || "",
350
+ target: data['target'] || data[:target] || 0,
351
+ code: intent_code,
352
+ reason: data['reason'] || data[:reason] || ""
353
+ )
354
+ end
355
+ end
356
+
357
+ #
358
+ # ServerIntent represents the type of change associated with the payload.
359
+ #
360
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
361
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
362
+ #
363
+ class ServerIntent
364
+ # @return [Payload] The payload
365
+ attr_reader :payload
366
+
367
+ #
368
+ # @param payload [Payload] The payload
369
+ #
370
+ def initialize(payload:)
371
+ @payload = payload
372
+ end
373
+
374
+ #
375
+ # Serializes the ServerIntent to a Hash.
376
+ #
377
+ # @return [Hash]
378
+ #
379
+ def to_h
380
+ {
381
+ payloads: [@payload.to_h],
382
+ }
383
+ end
384
+
385
+ #
386
+ # Deserializes a ServerIntent from a Hash.
387
+ #
388
+ # @param data [Hash] The hash representation
389
+ # @return [ServerIntent]
390
+ # @raise [ArgumentError] if required fields are missing or invalid
391
+ #
392
+ def self.from_h(data)
393
+ payloads = data['payloads'] || data[:payloads]
394
+
395
+ raise ArgumentError, "Invalid data for ServerIntent: 'payloads' key is missing or not an array" unless payloads.is_a?(Array)
396
+ raise ArgumentError, "Invalid data for ServerIntent: expected exactly one payload" unless payloads.length == 1
397
+
398
+ payload = payloads[0]
399
+ raise ArgumentError, "Invalid payload in ServerIntent: expected a hash" unless payload.is_a?(Hash)
400
+
401
+ ServerIntent.new(payload: Payload.from_h(payload))
402
+ end
403
+ end
404
+
405
+ #
406
+ # ChangeSetBuilder is a helper for constructing a ChangeSet.
407
+ #
408
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
409
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
410
+ #
411
+ class ChangeSetBuilder
412
+ # @return [String, nil] The current intent ({IntentCode})
413
+ attr_accessor :intent
414
+
415
+ # @return [Array<Change>] The changes
416
+ attr_accessor :changes
417
+
418
+ def initialize
419
+ @intent = nil
420
+ @changes = []
421
+ end
422
+
423
+ #
424
+ # Represents an intent that the current data is up-to-date and doesn't require changes.
425
+ #
426
+ # @return [ChangeSet]
427
+ #
428
+ def self.no_changes
429
+ ChangeSet.new(
430
+ intent_code: IntentCode::TRANSFER_NONE,
431
+ selector: Selector.no_selector,
432
+ changes: []
433
+ )
434
+ end
435
+
436
+ #
437
+ # Returns an empty ChangeSet, useful for initializing without data.
438
+ #
439
+ # @param selector [Selector] The selector
440
+ # @return [ChangeSet]
441
+ #
442
+ def self.empty(selector)
443
+ ChangeSet.new(
444
+ intent_code: IntentCode::TRANSFER_FULL,
445
+ selector: selector,
446
+ changes: []
447
+ )
448
+ end
449
+
450
+ #
451
+ # Begins a new change set with a given intent.
452
+ #
453
+ # @param intent [String] The intent code ({IntentCode})
454
+ # @return [void]
455
+ #
456
+ def start(intent)
457
+ @intent = intent
458
+ @changes = []
459
+ end
460
+
461
+ #
462
+ # Ensures that the current ChangeSetBuilder is prepared to handle changes.
463
+ #
464
+ # @return [void]
465
+ # @raise [RuntimeError] if no server-intent has been set
466
+ #
467
+ def expect_changes
468
+ raise "changeset: cannot expect changes without a server-intent" if @intent.nil?
469
+
470
+ return unless @intent == IntentCode::TRANSFER_NONE
471
+
472
+ @intent = IntentCode::TRANSFER_CHANGES
473
+ end
474
+
475
+ #
476
+ # Clears any existing changes while preserving the current intent.
477
+ #
478
+ # @return [void]
479
+ #
480
+ def reset
481
+ @changes = []
482
+ end
483
+
484
+ #
485
+ # Identifies a changeset with a selector and returns the completed changeset.
486
+ #
487
+ # @param selector [Selector] The selector
488
+ # @return [ChangeSet]
489
+ # @raise [RuntimeError] if no server-intent has been set
490
+ #
491
+ def finish(selector)
492
+ raise "changeset: cannot complete without a server-intent" if @intent.nil?
493
+
494
+ changeset = ChangeSet.new(
495
+ intent_code: @intent,
496
+ selector: selector,
497
+ changes: @changes
498
+ )
499
+ @changes = []
500
+
501
+ # Once a full transfer has been processed, all future changes should be
502
+ # assumed to be changes. Flag delivery can override this behavior by
503
+ # sending a new server intent to any connected stream.
504
+ @intent = IntentCode::TRANSFER_CHANGES if @intent == IntentCode::TRANSFER_FULL
505
+
506
+ changeset
507
+ end
508
+
509
+ #
510
+ # Adds a new object to the changeset.
511
+ #
512
+ # @param kind [String] The object kind ({ObjectKind})
513
+ # @param key [Symbol] The key
514
+ # @param version [Integer] The version
515
+ # @param obj [Hash] The object data
516
+ # @return [void]
517
+ #
518
+ def add_put(kind, key, version, obj)
519
+ @changes << Change.new(
520
+ action: ChangeType::PUT,
521
+ kind: kind,
522
+ key: key,
523
+ version: version,
524
+ object: obj
525
+ )
526
+ end
527
+
528
+ #
529
+ # Adds a deletion to the changeset.
530
+ #
531
+ # @param kind [String] The object kind ({ObjectKind})
532
+ # @param key [Symbol] The key
533
+ # @param version [Integer] The version
534
+ # @return [void]
535
+ #
536
+ def add_delete(kind, key, version)
537
+ @changes << Change.new(
538
+ action: ChangeType::DELETE,
539
+ kind: kind,
540
+ key: key,
541
+ version: version
542
+ )
543
+ end
544
+ end
545
+
546
+ #
547
+ # Update represents the results of a synchronizer's ongoing sync method.
548
+ #
549
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
550
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
551
+ #
552
+ class Update
553
+ # @return [Symbol] The data source state ({LaunchDarkly::Interfaces::DataSource::Status})
554
+ attr_reader :state
555
+
556
+ # @return [ChangeSet, nil] The change set
557
+ attr_reader :change_set
558
+
559
+ # @return [LaunchDarkly::Interfaces::DataSource::ErrorInfo, nil] Error information
560
+ attr_reader :error
561
+
562
+ # @return [Boolean] Whether to revert to FDv1
563
+ attr_reader :revert_to_fdv1
564
+
565
+ # @return [String, nil] The environment ID
566
+ attr_reader :environment_id
567
+
568
+ #
569
+ # @param state [Symbol] The data source state ({LaunchDarkly::Interfaces::DataSource::Status})
570
+ # @param change_set [ChangeSet, nil] The change set
571
+ # @param error [LaunchDarkly::Interfaces::DataSource::ErrorInfo, nil] Error information
572
+ # @param revert_to_fdv1 [Boolean] Whether to revert to FDv1
573
+ # @param environment_id [String, nil] The environment ID
574
+ #
575
+ def initialize(state:, change_set: nil, error: nil, revert_to_fdv1: false, environment_id: nil)
576
+ @state = state
577
+ @change_set = change_set
578
+ @error = error
579
+ @revert_to_fdv1 = revert_to_fdv1
580
+ @environment_id = environment_id
581
+ end
582
+ end
583
+
584
+ #
585
+ # SelectorStore represents a component capable of providing Selectors for data retrieval.
586
+ #
587
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
588
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
589
+ #
590
+ module SelectorStore
591
+ #
592
+ # Returns a Selector object that defines the criteria for data retrieval.
593
+ #
594
+ # @return [Selector]
595
+ #
596
+ def selector
597
+ raise NotImplementedError, "#{self.class} must implement #selector"
598
+ end
599
+ end
600
+
601
+ #
602
+ # ReadOnlyStore represents a read-only store interface for retrieving data.
603
+ #
604
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
605
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
606
+ #
607
+ module ReadOnlyStore
608
+ #
609
+ # Retrieves an item by kind and key.
610
+ #
611
+ # @param kind [LaunchDarkly::Impl::DataStore::DataKind] The data kind (e.g., LaunchDarkly::Impl::DataStore::FEATURES, LaunchDarkly::Impl::DataStore::SEGMENTS)
612
+ # @param key [String] The item key
613
+ # @return [Hash, nil] The item, or nil if not found or deleted
614
+ #
615
+ def get(kind, key)
616
+ raise NotImplementedError, "#{self.class} must implement #get"
617
+ end
618
+
619
+ #
620
+ # Retrieves all items of a given kind.
621
+ #
622
+ # @param kind [LaunchDarkly::Impl::DataStore::DataKind] The data kind (e.g., LaunchDarkly::Impl::DataStore::FEATURES, LaunchDarkly::Impl::DataStore::SEGMENTS)
623
+ # @return [Hash] Hash of keys to items (excluding deleted items)
624
+ #
625
+ def all(kind)
626
+ raise NotImplementedError, "#{self.class} must implement #all"
627
+ end
628
+
629
+ #
630
+ # Returns whether the store has been initialized.
631
+ #
632
+ # @return [Boolean]
633
+ #
634
+ def initialized?
635
+ raise NotImplementedError, "#{self.class} must implement #initialized?"
636
+ end
637
+ end
638
+
639
+ #
640
+ # Initializer represents a component capable of retrieving a single data result.
641
+ #
642
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
643
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
644
+ #
645
+ module Initializer
646
+ #
647
+ # Returns the name of the initializer.
648
+ #
649
+ # @return [String]
650
+ #
651
+ def name
652
+ raise NotImplementedError, "#{self.class} must implement #name"
653
+ end
654
+
655
+ #
656
+ # Retrieves the initial data set for the data source.
657
+ #
658
+ # @param selector_store [SelectorStore] Provides the Selector
659
+ # @return [LaunchDarkly::Result<Basis, String>]
660
+ #
661
+ def fetch(selector_store)
662
+ raise NotImplementedError, "#{self.class} must implement #fetch"
663
+ end
664
+ end
665
+
666
+ #
667
+ # Synchronizer represents a component capable of synchronizing data from an external source.
668
+ #
669
+ # This type is not stable, and not subject to any backwards compatibility guarantees or semantic versioning.
670
+ # It is in early access. If you want access to this feature please join the EAP. https://launchdarkly.com/docs/sdk/features/data-saving-mode
671
+ #
672
+ module Synchronizer
673
+ #
674
+ # Returns the name of the synchronizer.
675
+ #
676
+ # @return [String]
677
+ #
678
+ def name
679
+ raise NotImplementedError, "#{self.class} must implement #name"
680
+ end
681
+
682
+ #
683
+ # Begins the synchronization process, yielding Update objects.
684
+ #
685
+ # @param selector_store [SelectorStore] Provides the Selector
686
+ # @yieldparam update [Update] The update
687
+ # @return [void]
688
+ #
689
+ def sync(selector_store, &block)
690
+ raise NotImplementedError, "#{self.class} must implement #sync"
691
+ end
692
+
693
+ #
694
+ # Halts the synchronization process.
695
+ #
696
+ # @return [void]
697
+ #
698
+ def stop
699
+ raise NotImplementedError, "#{self.class} must implement #stop"
700
+ end
701
+ end
702
+ end
703
+ end
704
+ end