launchdarkly-server-sdk 8.7.1 → 8.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1692535bf245c0627c6e08cb87f168b11d7518d895bf9faacb2858da227f9d70
4
- data.tar.gz: fa60f044217ac286dd817b325ea87c431ce0399decc5ee84741638959b1a5697
3
+ metadata.gz: ad194623a6f35a835f5b80ce5068146bbb68ae0b7ee170824ffef66be5e5b152
4
+ data.tar.gz: 999fb27820fd61a422f14c62cf59a9a6f894fc34ac24be794a4144a13ad9dd35
5
5
  SHA512:
6
- metadata.gz: 92fc2011f8a0a8ca594863155081e60abfdeec0be8d50a1ebf051ed0a7a97406eac7560a12cf9a5c2beed7de71b58ff0dc720569b67f65f2f582fb2f7b1528c0
7
- data.tar.gz: e6a8b529997e0df8dfdf2a1b82c716211661bbeece2b50777146b5c6fdb7c8d97f69d23057ad6586b0730c9717fcb15b07a9808213da21ad7f9fbc91595c91f9
6
+ metadata.gz: be9ca147365077934dbeb17eb70df914679fb2dbf2360d971f7f2dd2fc1e72e2dfbf72be371ef5757bfaf9809cd7057f749936fcb89635d2a7ff530f8f590945
7
+ data.tar.gz: 2a8e19486d6897dd4eb5ed5bac30374087cb79817b1970218d7e360595da72a727360d50cddebdfcf3db6e340cffdfbbd8c042c5daece294b9233755a9a0d8cc
@@ -38,6 +38,7 @@ module LaunchDarkly
38
38
  meta[:version] = flag_state[:version]
39
39
  end
40
40
 
41
+ meta[:prerequisites] = flag_state[:prerequisites] unless flag_state[:prerequisites].nil? || flag_state[:prerequisites].empty?
41
42
  meta[:variation] = flag_state[:variation] unless flag_state[:variation].nil?
42
43
  meta[:trackEvents] = true if flag_state[:trackEvents]
43
44
  meta[:trackReason] = true if flag_state[:trackReason]
@@ -32,8 +32,16 @@ module LaunchDarkly
32
32
  def initialize(original_flag)
33
33
  @prereq_stack = EvaluatorStack.new(original_flag.key)
34
34
  @segment_stack = EvaluatorStack.new(nil)
35
+ @prerequisites = []
36
+ @depth = 0
35
37
  end
36
38
 
39
+ def record_evaluated_prereq_key(key)
40
+ @prerequisites.push(key) if @depth.zero?
41
+ end
42
+
43
+ attr_accessor :depth
44
+ attr_reader :prerequisites
37
45
  attr_reader :prereq_stack
38
46
  attr_reader :segment_stack
39
47
  end
@@ -135,7 +143,8 @@ module LaunchDarkly
135
143
  #
136
144
  # @param flag [LaunchDarkly::Impl::Model::FeatureFlag] the flag
137
145
  # @param context [LaunchDarkly::LDContext] the evaluation context
138
- # @return [EvalResult] the evaluation result
146
+ # @return [Array<EvalResult, EvaluatorState>] the evaluation result and a state object that may be used for
147
+ # inspecting the evaluation process
139
148
  def evaluate(flag, context)
140
149
  state = EvaluatorState.new(flag)
141
150
 
@@ -145,11 +154,11 @@ module LaunchDarkly
145
154
  rescue EvaluationException => exn
146
155
  LaunchDarkly::Util.log_exception(@logger, "Unexpected error when evaluating flag #{flag.key}", exn)
147
156
  result.detail = EvaluationDetail.new(nil, nil, EvaluationReason::error(exn.error_kind))
148
- return result
157
+ return result, state
149
158
  rescue => exn
150
159
  LaunchDarkly::Util.log_exception(@logger, "Unexpected error when evaluating flag #{flag.key}", exn)
151
160
  result.detail = EvaluationDetail.new(nil, nil, EvaluationReason::error(EvaluationReason::ERROR_EXCEPTION))
152
- return result
161
+ return result, state
153
162
  end
154
163
 
155
164
  unless result.big_segments_status.nil?
@@ -159,7 +168,7 @@ module LaunchDarkly
159
168
  detail.reason.with_big_segments_status(result.big_segments_status))
160
169
  end
161
170
  result.detail = detail
162
- result
171
+ [result, state]
163
172
  end
164
173
 
165
174
  # @param segment [LaunchDarkly::Impl::Model::Segment]
@@ -223,13 +232,16 @@ module LaunchDarkly
223
232
  )
224
233
  end
225
234
 
235
+ state.record_evaluated_prereq_key(prereq_key)
226
236
  prereq_flag = @get_flag.call(prereq_key)
227
237
 
228
238
  if prereq_flag.nil?
229
239
  @logger.error { "[LDClient] Could not retrieve prerequisite flag \"#{prereq_key}\" when evaluating \"#{flag.key}\"" }
230
240
  prereq_ok = false
231
241
  else
242
+ state.depth += 1
232
243
  prereq_res = eval_internal(prereq_flag, context, eval_result, state)
244
+ state.depth -= 1
233
245
  # Note that if the prerequisite flag is off, we don't consider it a match no matter what its
234
246
  # off variation was. But we still need to evaluate it in order to generate an event.
235
247
  if !prereq_flag.on || prereq_res.variation_index != prerequisite.variation
@@ -546,7 +546,8 @@ module LaunchDarkly
546
546
  next
547
547
  end
548
548
  begin
549
- detail = @evaluator.evaluate(f, context).detail
549
+ (eval_result, eval_state) = @evaluator.evaluate(f, context)
550
+ detail = eval_result.detail
550
551
  rescue => exn
551
552
  detail = EvaluationDetail.new(nil, nil, EvaluationReason::error(EvaluationReason::ERROR_EXCEPTION))
552
553
  Util.log_exception(@config.logger, "Error evaluating flag \"#{k}\" in all_flags_state", exn)
@@ -558,6 +559,7 @@ module LaunchDarkly
558
559
  value: detail.value,
559
560
  variation: detail.variation_index,
560
561
  reason: detail.reason,
562
+ prerequisites: eval_state.prerequisites,
561
563
  version: f[:version],
562
564
  trackEvents: f[:trackEvents] || requires_experiment_data,
563
565
  trackReason: requires_experiment_data,
@@ -705,7 +707,7 @@ module LaunchDarkly
705
707
  end
706
708
 
707
709
  begin
708
- res = @evaluator.evaluate(feature, context)
710
+ (res, _) = @evaluator.evaluate(feature, context)
709
711
  unless res.prereq_evals.nil?
710
712
  res.prereq_evals.each do |prereq_eval|
711
713
  record_prereq_flag_eval(prereq_eval.prereq_flag, prereq_eval.prereq_of_flag, context, prereq_eval.detail, with_reasons)
@@ -1,3 +1,3 @@
1
1
  module LaunchDarkly
2
- VERSION = "8.7.1" # x-release-please-version
2
+ VERSION = "8.8.0" # x-release-please-version
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchdarkly-server-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.7.1
4
+ version: 8.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-07 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb