determinator 2.7.0 → 2.7.1

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: dffc736e777d38ceafbe8ce45d0a01f960341a542a2b93b6ba13b77f1479d291
4
- data.tar.gz: 7be7ecbd850faac8009e031d41eea1d9679d5f2c43923cbc8ad688c6c1411f3a
3
+ metadata.gz: 54342b4c971ac191030bf2aa264c419e0afc3f8dc1b2558f140ad99b021dbb7c
4
+ data.tar.gz: '049f2d041afbaa2556f08f636c6ff43397f0625c910a2a05ee95b57875882d14'
5
5
  SHA512:
6
- metadata.gz: 5b959c8460720151fd7455f1bbc556af6f61f327c7092bad148d52bc9141c3e5144c17a7c6cb45c483322f9dc65ee047ceccc1a048eea15e46544f6aa4fb06e1
7
- data.tar.gz: b8b08c82db627c37d8630dd56111d0361b3c5a5874286d447015ac98d0d25a2421631f589f4438b26d71bc9ed58f5141d8084563dd37c24c7f5ca71faac62156
6
+ metadata.gz: 381afb82fb6f1e0085aaa20ad681562f2ced69c4196bee3d3ac7fb96e186df748a73f462d73711a0e36e520031ca20d91c7a5ec7d9b61d13d8bf76464629a51c
7
+ data.tar.gz: e6676ae384f5d61b2af9f5f248e55d88ffd6dff680672e353cab4d380d2564f5c9947ad59f0e483e3ffbe30de6e7cbba029ba8ead4feb660f874d93867c24eae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.7.1
2
+
3
+ Feature:
4
+ - Add `before_retrieve` and `after_retrieve` hooks for `Determinator::Retrieve::HttpRetriever`
5
+
1
6
  # 2.7.0
2
7
 
3
8
  ⚠️ This release includes breaking changes ⚠️
data/README.md CHANGED
@@ -156,6 +156,23 @@ or in instances where the event bus provides a full feature object with a name i
156
156
 
157
157
  This will expire both the limited local cache and the larger shared cache.
158
158
 
159
+ ### Using hooks for retriever
160
+
161
+ ```HttpRetriever``` has ```before_retrieve``` and ```after_retrieve``` hooks.
162
+
163
+ Example of usage:
164
+ ```ruby
165
+ http_retriever = Determinator::Retrieve::HttpRetriever.new(faraday_connection)
166
+
167
+ http_retriever.before_retrieve do
168
+ do_something
169
+ end
170
+
171
+ http_retriever.after_retrieve do |status, err|
172
+ raise err if err
173
+ do_something(status)
174
+ end
175
+ ```
159
176
  ## Further Usage
160
177
 
161
178
  Once this is done you can ask for a determination like this:
@@ -10,11 +10,14 @@ module Determinator
10
10
  end
11
11
 
12
12
  def retrieve(name)
13
+ before_hook
13
14
  response = @connection.get("/features/#{name}")
15
+ after_hook(response.status)
14
16
  return Determinator::Serializers::JSON.load(response.body) if response.status == 200
15
17
  return MissingResponse.new if response.status == 404
16
18
  rescue => e
17
19
  Determinator.notice_error(e)
20
+ after_hook(500, e)
18
21
  ErrorResponse.new
19
22
  end
20
23
 
@@ -29,6 +32,28 @@ module Determinator
29
32
  def get_name(url)
30
33
  (url.match('features\/(.*)\z') || [])[1]
31
34
  end
35
+
36
+ def before_retrieve(&block)
37
+ @before_retrieve = block
38
+ end
39
+
40
+ def after_retrieve(&block)
41
+ @after_retrieve = block
42
+ end
43
+
44
+ private
45
+
46
+ def after_hook(status, error = nil)
47
+ return unless @after_retrieve
48
+
49
+ @after_retrieve.call(status, error)
50
+ end
51
+
52
+ def before_hook
53
+ return unless @before_retrieve
54
+
55
+ @before_retrieve.call
56
+ end
32
57
  end
33
58
  end
34
59
  end
@@ -1,3 +1,3 @@
1
1
  module Determinator
2
- VERSION = '2.7.0'
2
+ VERSION = '2.7.1'
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.7.0
4
+ version: 2.7.1
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: 2021-04-14 00:00:00.000000000 Z
11
+ date: 2021-12-13 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
254
+ rubygems_version: 3.0.3.1
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: Determine which experiments and features a specific actor should see.