determinator 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/determinator.gemspec +1 -1
- data/lib/determinator/retrieve/routemaster.rb +8 -7
- data/lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb +29 -0
- data/lib/determinator/version.rb +1 -1
- metadata +6 -6
- data/lib/determinator/retrieve/routemaster_indexing_middleware.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d000e613ee7aeaf88c08bf5588ad6e076722e9da
|
4
|
+
data.tar.gz: b133723daaea81147a3abb6ca2300717669dced2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59a22af903dd9f0cce9a714617efb5b7a38a6933245d2299a50e1d999784fd328361b5ba3f50751f55d8c57e49fac6c76059a9d8900dcfa93d405f0fa4b76917
|
7
|
+
data.tar.gz: 7da1374c9d8588b25d3b9dddfb7b407a0a80a614b9c3eb383d9f11f837526d27339364025aa0240c434d8b59f5194f167380e020c5fdeae9816924d65fceeb3f
|
data/determinator.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "routemaster-drain", "~> 2.
|
23
|
+
spec.add_runtime_dependency "routemaster-drain", "~> 2.5"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.13"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'routemaster/drain/caching'
|
3
3
|
require 'routemaster/responses/hateoas_response'
|
4
|
-
require 'determinator/retrieve/
|
4
|
+
require 'determinator/retrieve/routemaster_feature_id_cache_warmer'
|
5
5
|
|
6
6
|
module Determinator
|
7
7
|
module Retrieve
|
@@ -24,11 +24,12 @@ module Determinator
|
|
24
24
|
# @param :discovery_url [String] The bootstrap URL of the instance of Florence which defines Features.
|
25
25
|
def initialize(discovery_url:)
|
26
26
|
client = ::Routemaster::APIClient.new(
|
27
|
-
response_class: ::Routemaster::Responses::HateoasResponse
|
28
|
-
middlewares: [RoutemasterIndexingMiddleware]
|
27
|
+
response_class: ::Routemaster::Responses::HateoasResponse
|
29
28
|
)
|
30
29
|
@routemaster = client.discover(discovery_url)
|
31
|
-
@routemaster_app = ::Routemaster::Drain::Caching.new
|
30
|
+
@routemaster_app = ::Routemaster::Drain::Caching.new(
|
31
|
+
siphon_events: { 'features' => RoutemasterFeatureIdCacheWarmer }
|
32
|
+
)
|
32
33
|
end
|
33
34
|
|
34
35
|
def retrieve(feature_name)
|
@@ -45,11 +46,11 @@ module Determinator
|
|
45
46
|
target_groups: obj.body.target_groups.map { |tg|
|
46
47
|
TargetGroup.new(
|
47
48
|
rollout: tg.rollout,
|
48
|
-
constraints: tg.constraints.
|
49
|
+
constraints: tg.constraints.to_h
|
49
50
|
)
|
50
51
|
},
|
51
|
-
variants: obj.body.variants.
|
52
|
-
overrides: obj.body.overrides.
|
52
|
+
variants: obj.body.variants.to_h,
|
53
|
+
overrides: obj.body.overrides.to_h
|
53
54
|
)
|
54
55
|
rescue ::Routemaster::Errors::ResourceNotFound
|
55
56
|
nil
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Determinator
|
2
|
+
module Retrieve
|
3
|
+
class RoutemasterFeatureIdCacheWarmer
|
4
|
+
def initialize(payload)
|
5
|
+
@payload = payload
|
6
|
+
end
|
7
|
+
|
8
|
+
def call
|
9
|
+
response = client.get(@payload['url']).body
|
10
|
+
if valid_feature_response?(response)
|
11
|
+
key = Routemaster.index_cache_key(response['name'])
|
12
|
+
::Routemaster::Config.cache_redis.set(key, response['id'])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def client
|
19
|
+
@client ||= ::Routemaster::APIClient.new(
|
20
|
+
response_class: ::Routemaster::Responses::HateoasResponse
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid_feature_response?(response)
|
25
|
+
response['id'] && response['name'] && response['bucket_type']
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
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: 0.
|
4
|
+
version: 0.2.0
|
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: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: routemaster-drain
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,7 +178,7 @@ files:
|
|
178
178
|
- lib/determinator/control.rb
|
179
179
|
- lib/determinator/feature.rb
|
180
180
|
- lib/determinator/retrieve/routemaster.rb
|
181
|
-
- lib/determinator/retrieve/
|
181
|
+
- lib/determinator/retrieve/routemaster_feature_id_cache_warmer.rb
|
182
182
|
- lib/determinator/target_group.rb
|
183
183
|
- lib/determinator/version.rb
|
184
184
|
homepage: https://github.com/deliveroo/determinator
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
203
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.6.8
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: Determine which experiments and features a specific actor should see.
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Determinator
|
2
|
-
module Retrieve
|
3
|
-
# Middleware which indexes features by their name, so we can look up a feature by name
|
4
|
-
# and find the details (which are only accessible by ID)
|
5
|
-
class RoutemasterIndexingMiddleware
|
6
|
-
def initialize(app)
|
7
|
-
@app = app
|
8
|
-
end
|
9
|
-
|
10
|
-
def call(env)
|
11
|
-
content = JSON.parse(env.body)
|
12
|
-
|
13
|
-
if content_describes_feature?(content)
|
14
|
-
key = Routemaster.index_cache_key(content['name'])
|
15
|
-
::Routemaster::Config.cache_redis.set(key, content['id'])
|
16
|
-
end
|
17
|
-
|
18
|
-
@app.call(env)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def content_describes_feature?(content)
|
24
|
-
content['id'] && content['name'] && content['bucket_type']
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|