determinator 2.9.2 → 2.9.3

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: 14629ea70bc6ef083ef707b43a00dcf3b5cb1e8234ad91c202efd5a70b1e6dac
4
- data.tar.gz: a7b8af30577d40b93c948e0ff726ac12236fee899ae5be8f9b165e1e934a93d0
3
+ metadata.gz: '009b70756437db9c6dc88091752e870588fe171bc729d7ec16cfcddb8e8033e2'
4
+ data.tar.gz: ac042540a864bc4af7fffd016b4e0d6a94243e1c764d6770c71b818a516d77fc
5
5
  SHA512:
6
- metadata.gz: 4daeb35cd313579c5916e1a88300062e99b4185d6dab9fa5e825e1de56d65d8d2028ba37d22da398b730103f9d6f7ca3725d331b42b90e204d2c016eacce43ae
7
- data.tar.gz: 6fc1b952241c2a8d58a94cdc0fe5f7c9255d41ed1e1228f5b35da4a16bebd94539388b1b1f4b0f7bec4ec17f1e17569006443e0ba787df5d9a54e822db68759e
6
+ metadata.gz: c1a7f55c7e672d7e647b23ed79ba84af1fdeeb761460d8126742564d395ad541b53cd050c1bbf232933ddfca3f8eb9b6124c21d3f661c7b1cc37d1ba8d383c42
7
+ data.tar.gz: 9a70fe0809c9309cb330571fef09511debcbf951d9cf73ab2eae8ec22001adc4eaba3f8d684b1ed7e8943454c350196471914e9d10d20781b4c647616d6ba918
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 2.9.3
2
+
3
+ Feature:
4
+ - Add optional `feature` argument to `feature_flag_on?` and `which_variant` methods of ActorControl, to reuse an existing feature.
5
+ - Add mutex to synchronise access to caches in Cache::FetchWrapper.
6
+
1
7
  # 2.9.2
2
8
 
3
9
  Bug fix:
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in determinator.gemspec
4
4
  gemspec
5
+
6
+ gem 'byebug'
@@ -14,22 +14,24 @@ module Determinator
14
14
  end
15
15
 
16
16
  # @see Determinator::Control#which_variant
17
- def which_variant(name, properties: {})
17
+ def which_variant(name, properties: {}, feature: nil)
18
18
  controller.which_variant(
19
19
  name,
20
20
  id: id,
21
21
  guid: guid,
22
- properties: default_properties.merge(properties)
22
+ properties: default_properties.merge(properties),
23
+ feature: feature
23
24
  )
24
25
  end
25
26
 
26
27
  # @see Determinator::Control#feature_flag_on?
27
- def feature_flag_on?(name, properties: {})
28
+ def feature_flag_on?(name, properties: {}, feature: nil)
28
29
  controller.feature_flag_on?(
29
30
  name,
30
31
  id: id,
31
32
  guid: guid,
32
- properties: default_properties.merge(properties)
33
+ properties: default_properties.merge(properties),
34
+ feature: feature
33
35
  )
34
36
  end
35
37
 
@@ -7,12 +7,16 @@ module Determinator
7
7
  def initialize(*caches, cache_missing: true)
8
8
  @cache_missing = cache_missing
9
9
  @caches = caches
10
+ @mutex = Mutex.new
10
11
  end
11
12
 
12
13
  # Call walks through each cache, returning a value if the item exists in
13
14
  # any cache, otherwise popularing each cache with the value of yield.
14
15
  def call(feature_name)
15
- value = read_and_upfill(feature_name)
16
+ value =
17
+ @mutex.synchronize do
18
+ read_and_upfill(feature_name)
19
+ end
16
20
 
17
21
  # if the value is missing and we cache it, return the missing response
18
22
  return value if value.is_a?(MissingResponse) && @cache_missing
@@ -22,14 +26,20 @@ module Determinator
22
26
 
23
27
  value_to_write = yield
24
28
  return value_to_write if value_to_write.is_a?(ErrorResponse)
25
- @caches.each do |cache|
26
- cache.write(key(feature_name), value_to_write)
29
+
30
+ @mutex.synchronize do
31
+ @caches.each do |cache|
32
+ cache.write(key(feature_name), value_to_write)
33
+ end
27
34
  end
35
+
28
36
  return value_to_write
29
37
  end
30
38
 
31
39
  def expire(feature_name)
32
- @caches.each{ |c| c.delete(key(feature_name)) }
40
+ @mutex.synchronize do
41
+ @caches.each{ |c| c.delete(key(feature_name)) }
42
+ end
33
43
  end
34
44
 
35
45
  private
@@ -52,9 +62,11 @@ module Determinator
52
62
  @caches[0...index].each do |cache|
53
63
  cache.write(key(feature_name), value)
54
64
  end
65
+
55
66
  return value
56
67
  end
57
68
  end
69
+
58
70
  return nil
59
71
  end
60
72
  end
@@ -1,3 +1,3 @@
1
1
  module Determinator
2
- VERSION = '2.9.2'
2
+ VERSION = '2.9.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: determinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.2
4
+ version: 2.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Hastings-Spital
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-12 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -251,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  requirements: []
254
- rubygems_version: 3.0.3.1
254
+ rubygems_version: 3.1.6
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: Determine which experiments and features a specific actor should see.