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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +17 -0
- data/lib/determinator/retrieve/http_retriever.rb +25 -0
- data/lib/determinator/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54342b4c971ac191030bf2aa264c419e0afc3f8dc1b2558f140ad99b021dbb7c
|
4
|
+
data.tar.gz: '049f2d041afbaa2556f08f636c6ff43397f0625c910a2a05ee95b57875882d14'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 381afb82fb6f1e0085aaa20ad681562f2ced69c4196bee3d3ac7fb96e186df748a73f462d73711a0e36e520031ca20d91c7a5ec7d9b61d13d8bf76464629a51c
|
7
|
+
data.tar.gz: e6676ae384f5d61b2af9f5f248e55d88ffd6dff680672e353cab4d380d2564f5c9947ad59f0e483e3ffbe30de6e7cbba029ba8ead4feb660f874d93867c24eae
|
data/CHANGELOG.md
CHANGED
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
|
data/lib/determinator/version.rb
CHANGED
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.
|
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-
|
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.
|