determinator 1.2.0 → 2.0.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
- SHA1:
3
- metadata.gz: d219da75a8bee8e9cd53595730a49efb4749ed05
4
- data.tar.gz: 92bdf5062b3f2d5a0c572fbc708a9d58d95f9ff4
2
+ SHA256:
3
+ metadata.gz: c1b781c3d75121ccfad51eae6fa2faa71a6026d24570c3cf73daeb330e80f5e6
4
+ data.tar.gz: 3adf8888c9f6f1e70b619afbd8b819be6981701274f502f5017688229a2f355f
5
5
  SHA512:
6
- metadata.gz: 9aa1117cfb1ae48053aa212e945563a8aeca91067db81b51b3e006cbabcbcd59dc29c42b59f4b3cdbc26a47fa45851a7a8b961c55e3176fd6563c8c72473790d
7
- data.tar.gz: a61246f9e1bea5e7907b098bc594945dd83f3f93ec332a7308ca45b4d0e771a17cd2466e3ec2f03f0ecf4d4987cc54f96a1eb3001327a8e67f15ca8946c8c208
6
+ metadata.gz: f154018834b5fc5e7ff5f624272487a343c633ebcb5124b34c522694e8e0a0df606999243f0994d1e8d836eaec07fb3be8ef140d457542b948a8ddc4e2cea2ea
7
+ data.tar.gz: c4d0bbbade1370255a2d33155d443ce8e440673daf0fc18c975eb268f1efc0ad56d0cf73fdf36aa4b24f708d1826f3c53de424e71e0b3505c9a5778f190c5b84
@@ -0,0 +1,78 @@
1
+ # To update the build configuration, edit the "builds" array below and run:
2
+ # erb .circleci/config.yml.erb > .circleci/config.yml
3
+
4
+ version: 2
5
+ jobs:
6
+
7
+ build_2.4:
8
+ docker:
9
+ - image: circleci/ruby:2.4
10
+ steps:
11
+ - checkout
12
+
13
+ - run:
14
+ name: Bundle Install
15
+ command: bundle install
16
+
17
+ - run:
18
+ name: Include standard tests
19
+ command: git submodule update --init
20
+
21
+ - run:
22
+ name: Run rspec
23
+ command: |
24
+ bundle exec rspec --format documentation
25
+
26
+
27
+ build_2.5:
28
+ docker:
29
+ - image: circleci/ruby:2.5
30
+ steps:
31
+ - checkout
32
+
33
+ - run:
34
+ name: Bundle Install
35
+ command: bundle install
36
+
37
+ - run:
38
+ name: Include standard tests
39
+ command: git submodule update --init
40
+
41
+ - run:
42
+ name: Run rspec
43
+ command: |
44
+ bundle exec rspec --format documentation
45
+
46
+
47
+ build_2.6:
48
+ docker:
49
+ - image: circleci/ruby:2.6
50
+ steps:
51
+ - checkout
52
+
53
+ - run:
54
+ name: Bundle Install
55
+ command: bundle install
56
+
57
+ - run:
58
+ name: Include standard tests
59
+ command: git submodule update --init
60
+
61
+ - run:
62
+ name: Run rspec
63
+ command: |
64
+ bundle exec rspec --format documentation
65
+
66
+
67
+
68
+ workflows:
69
+ version: 2
70
+ test:
71
+ jobs:
72
+
73
+ - build_2.4
74
+
75
+ - build_2.5
76
+
77
+ - build_2.6
78
+
@@ -0,0 +1,36 @@
1
+ # To update the build configuration, edit the "builds" array below and run:
2
+ # erb .circleci/config.yml.erb > .circleci/config.yml
3
+ <%
4
+ builds = %w(2.4 2.5 2.6)
5
+ %>
6
+ version: 2
7
+ jobs:
8
+ <% builds.each do |ruby| %>
9
+ build_<%= ruby %>:
10
+ docker:
11
+ - image: circleci/ruby:<%= ruby %>
12
+ steps:
13
+ - checkout
14
+
15
+ - run:
16
+ name: Bundle Install
17
+ command: bundle install
18
+
19
+ - run:
20
+ name: Include standard tests
21
+ command: git submodule update --init
22
+
23
+ - run:
24
+ name: Run rspec
25
+ command: |
26
+ bundle exec rspec --format documentation
27
+
28
+ <% end %>
29
+
30
+ workflows:
31
+ version: 2
32
+ test:
33
+ jobs:
34
+ <% builds.each do |ruby| %>
35
+ - build_<%= ruby %>
36
+ <% end %>
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v2.0.0 (2019-02-19)
2
+
3
+ Breaking change:
4
+ - Removes routemaster-drain support, the gem is also no longer a dependency. (#55)
5
+
6
+ Feature:
7
+ - Adds retriever for Dynaconf. (#55)
8
+
1
9
  # v1.2.0 (2018-06-12)
2
10
 
3
11
  Feature:
data/README.md CHANGED
@@ -82,11 +82,11 @@ Determinator requires a initialiser block somewhere in your application's boot p
82
82
  ```ruby
83
83
  # config/initializers/determinator.rb
84
84
 
85
- require 'determinator/retrieve/routemaster'
85
+ require 'determinator/retrieve/dynaconf'
86
86
  require 'active_support/cache'
87
87
 
88
88
  Determinator.configure(
89
- retrieval: Determinator::Retrieve::Routemaster.new(discovery_url: 'https://flo.dev/'),
89
+ retrieval: Determinator::Retrieve::Dynaconf.new(host: 'localhost:2345'),
90
90
  feature_cache: Determinator::Cache::FetchWrapper.new(
91
91
  ActiveSupport::Cache::MemoryStore.new(expires_in: 1.minute)
92
92
  )
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", "~> 3.0"
23
+ spec.add_runtime_dependency "faraday"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.13"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "guard-rspec", "~> 4.7"
30
30
  spec.add_development_dependency "factory_girl", "~> 4.8"
31
31
  spec.add_development_dependency "semantic", "~> 1.6"
32
+ spec.add_development_dependency 'webmock'
32
33
  end
@@ -1,157 +1,129 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- determinator (1.0.0)
5
- routemaster-drain (~> 3.0)
4
+ determinator (1.2.0)
5
+ faraday
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.0.2)
11
- actionpack (= 5.0.2)
10
+ actioncable (5.0.7)
11
+ actionpack (= 5.0.7)
12
12
  nio4r (>= 1.2, < 3.0)
13
13
  websocket-driver (~> 0.6.1)
14
- actionmailer (5.0.2)
15
- actionpack (= 5.0.2)
16
- actionview (= 5.0.2)
17
- activejob (= 5.0.2)
14
+ actionmailer (5.0.7)
15
+ actionpack (= 5.0.7)
16
+ actionview (= 5.0.7)
17
+ activejob (= 5.0.7)
18
18
  mail (~> 2.5, >= 2.5.4)
19
19
  rails-dom-testing (~> 2.0)
20
- actionpack (5.0.2)
21
- actionview (= 5.0.2)
22
- activesupport (= 5.0.2)
20
+ actionpack (5.0.7)
21
+ actionview (= 5.0.7)
22
+ activesupport (= 5.0.7)
23
23
  rack (~> 2.0)
24
24
  rack-test (~> 0.6.3)
25
25
  rails-dom-testing (~> 2.0)
26
26
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.0.2)
28
- activesupport (= 5.0.2)
27
+ actionview (5.0.7)
28
+ activesupport (= 5.0.7)
29
29
  builder (~> 3.1)
30
30
  erubis (~> 2.7.0)
31
31
  rails-dom-testing (~> 2.0)
32
32
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.0.2)
34
- activesupport (= 5.0.2)
33
+ activejob (5.0.7)
34
+ activesupport (= 5.0.7)
35
35
  globalid (>= 0.3.6)
36
- activemodel (5.0.2)
37
- activesupport (= 5.0.2)
38
- activerecord (5.0.2)
39
- activemodel (= 5.0.2)
40
- activesupport (= 5.0.2)
36
+ activemodel (5.0.7)
37
+ activesupport (= 5.0.7)
38
+ activerecord (5.0.7)
39
+ activemodel (= 5.0.7)
40
+ activesupport (= 5.0.7)
41
41
  arel (~> 7.0)
42
- activesupport (5.0.2)
42
+ activesupport (5.0.7)
43
43
  concurrent-ruby (~> 1.0, >= 1.0.2)
44
- i18n (~> 0.7)
44
+ i18n (>= 0.7, < 2)
45
45
  minitest (~> 5.1)
46
46
  tzinfo (~> 1.1)
47
- addressable (2.5.2)
48
- public_suffix (>= 2.0.2, < 4.0)
49
47
  arel (7.1.4)
50
48
  builder (3.2.3)
51
- byebug (9.0.6)
52
- circuitbox (1.1.1)
53
- activesupport
54
- moneta
49
+ byebug (10.0.2)
55
50
  concurrent-ruby (1.0.5)
56
- connection_pool (2.2.1)
57
- dotenv (2.2.0)
58
- dotenv-rails (2.2.0)
59
- dotenv (= 2.2.0)
60
- railties (>= 3.2, < 5.1)
51
+ connection_pool (2.2.2)
52
+ crass (1.0.4)
53
+ dotenv (2.4.0)
54
+ dotenv-rails (2.4.0)
55
+ dotenv (= 2.4.0)
56
+ railties (>= 3.2, < 6.0)
61
57
  erubis (2.7.0)
62
- ethon (0.11.0)
63
- ffi (>= 1.3.0)
64
- faraday (0.14.0)
58
+ faraday (0.15.4)
65
59
  multipart-post (>= 1.2, < 3)
66
- faraday_middleware (0.12.2)
67
- faraday (>= 0.7.4, < 1.0)
68
- ffi (1.9.21)
69
- globalid (0.3.7)
70
- activesupport (>= 4.1.0)
71
- hashie (3.5.7)
72
- i18n (0.8.1)
73
- loofah (2.0.3)
60
+ globalid (0.4.1)
61
+ activesupport (>= 4.2.0)
62
+ i18n (1.0.1)
63
+ concurrent-ruby (~> 1.0)
64
+ loofah (2.2.2)
65
+ crass (~> 1.0.2)
74
66
  nokogiri (>= 1.5.9)
75
- mail (2.6.4)
76
- mime-types (>= 1.16, < 4)
77
- method_source (0.8.2)
78
- mime-types (3.1)
79
- mime-types-data (~> 3.2015)
80
- mime-types-data (3.2016.0521)
67
+ mail (2.7.0)
68
+ mini_mime (>= 0.1.1)
69
+ method_source (0.9.0)
70
+ mini_mime (1.0.0)
81
71
  mini_portile2 (2.3.0)
82
- minitest (5.10.1)
83
- moneta (1.0.0)
72
+ minitest (5.11.3)
84
73
  multipart-post (2.0.0)
85
- nio4r (2.0.0)
86
- nokogiri (1.8.1)
74
+ nio4r (2.3.1)
75
+ nokogiri (1.8.2)
87
76
  mini_portile2 (~> 2.3.0)
88
- public_suffix (3.0.1)
89
- puma (3.8.2)
90
- rack (2.0.1)
91
- rack-protection (1.5.3)
77
+ puma (3.11.4)
78
+ rack (2.0.5)
79
+ rack-protection (2.0.3)
92
80
  rack
93
81
  rack-test (0.6.3)
94
82
  rack (>= 1.0)
95
- rails (5.0.2)
96
- actioncable (= 5.0.2)
97
- actionmailer (= 5.0.2)
98
- actionpack (= 5.0.2)
99
- actionview (= 5.0.2)
100
- activejob (= 5.0.2)
101
- activemodel (= 5.0.2)
102
- activerecord (= 5.0.2)
103
- activesupport (= 5.0.2)
104
- bundler (>= 1.3.0, < 2.0)
105
- railties (= 5.0.2)
83
+ rails (5.0.7)
84
+ actioncable (= 5.0.7)
85
+ actionmailer (= 5.0.7)
86
+ actionpack (= 5.0.7)
87
+ actionview (= 5.0.7)
88
+ activejob (= 5.0.7)
89
+ activemodel (= 5.0.7)
90
+ activerecord (= 5.0.7)
91
+ activesupport (= 5.0.7)
92
+ bundler (>= 1.3.0)
93
+ railties (= 5.0.7)
106
94
  sprockets-rails (>= 2.0.0)
107
- rails-dom-testing (2.0.2)
108
- activesupport (>= 4.2.0, < 6.0)
109
- nokogiri (~> 1.6)
110
- rails-html-sanitizer (1.0.3)
111
- loofah (~> 2.0)
112
- railties (5.0.2)
113
- actionpack (= 5.0.2)
114
- activesupport (= 5.0.2)
95
+ rails-dom-testing (2.0.3)
96
+ activesupport (>= 4.2.0)
97
+ nokogiri (>= 1.6)
98
+ rails-html-sanitizer (1.0.4)
99
+ loofah (~> 2.2, >= 2.2.2)
100
+ railties (5.0.7)
101
+ actionpack (= 5.0.7)
102
+ activesupport (= 5.0.7)
115
103
  method_source
116
104
  rake (>= 0.8.7)
117
105
  thor (>= 0.18.1, < 2.0)
118
- rake (12.0.0)
119
- redis (3.3.3)
120
- redis-namespace (1.6.0)
121
- redis (>= 3.0.4)
122
- routemaster-drain (3.4.0)
123
- addressable
124
- circuitbox
125
- concurrent-ruby
126
- faraday (>= 0.9.0)
127
- faraday_middleware
128
- hashie
129
- rack (>= 1.4.5)
130
- redis-namespace
131
- typhoeus (~> 1.1)
132
- wisper (~> 1.6.1)
133
- sidekiq (4.2.10)
106
+ rake (12.3.1)
107
+ redis (4.0.1)
108
+ sidekiq (5.1.3)
134
109
  concurrent-ruby (~> 1.0)
135
110
  connection_pool (~> 2.2, >= 2.2.0)
136
111
  rack-protection (>= 1.5.0)
137
- redis (~> 3.2, >= 3.2.1)
112
+ redis (>= 3.3.5, < 5)
138
113
  sprockets (3.7.1)
139
114
  concurrent-ruby (~> 1.0)
140
115
  rack (> 1, < 3)
141
- sprockets-rails (3.2.0)
116
+ sprockets-rails (3.2.1)
142
117
  actionpack (>= 4.0)
143
118
  activesupport (>= 4.0)
144
119
  sprockets (>= 3.0.0)
145
- thor (0.19.4)
120
+ thor (0.20.0)
146
121
  thread_safe (0.3.6)
147
- typhoeus (1.3.0)
148
- ethon (>= 0.9.0)
149
- tzinfo (1.2.3)
122
+ tzinfo (1.2.5)
150
123
  thread_safe (~> 0.1)
151
124
  websocket-driver (0.6.5)
152
125
  websocket-extensions (>= 0.1.0)
153
- websocket-extensions (0.1.2)
154
- wisper (1.6.1)
126
+ websocket-extensions (0.1.3)
155
127
 
156
128
  PLATFORMS
157
129
  ruby
@@ -165,4 +137,4 @@ DEPENDENCIES
165
137
  sidekiq
166
138
 
167
139
  BUNDLED WITH
168
- 1.16.0
140
+ 1.17.3
@@ -1,6 +1,6 @@
1
1
  # Rails and Determinator example
2
2
 
3
- This example Rails app has been configured so that Determinator is correctly configured, and (with an instance of the Actor Tracking Service and Routemaster running alongside) it will correctly determine feature rollout and experiment variant selection.
3
+ This example Rails app has been configured so that Determinator is correctly configured, and (with an instance of the Actor Tracking Service) it will correctly determine feature rollout and experiment variant selection.
4
4
 
5
5
  ## Points of interest
6
6
 
@@ -8,16 +8,6 @@ This example Rails app has been configured so that Determinator is correctly con
8
8
 
9
9
  This file sets up the singleton Determinator instance for the application.
10
10
 
11
- ### `config/initializers/routemaster.rb`
12
-
13
- Uses Routemaster::Client to subscribe to the `features` topic, with a calback url matching what's set up in the routes file
14
-
15
- ### `config/routes.rb`
16
-
17
- Sets up a simple routemaster drain endpoint, using the `CacheBusting`. Other Drains are available with additional features
18
-
19
- https://github.com/deliveroo/routemaster-drain
20
-
21
11
  ### `app/controllers/index_controller.rb`
22
12
 
23
13
  An example of how Determinator can be used for feature flags and experiments.
@@ -27,7 +17,3 @@ An example of how Determinator can be used for feature flags and experiments.
27
17
  An example of how a GUID could be assigned to every visitor to the site. Storing this in the session means it will be reset upon log out.
28
18
 
29
19
  The `determinator` method memoizes the instance of the `ActorControl` helper class for ease of use throughout this request.
30
-
31
- ### `config/application.rb`
32
-
33
- Ensure you've required the job runner backend appropriate for your set up. Routemaster Drain currently supports Sidekiq and Resque.
@@ -6,9 +6,6 @@ require "active_job/railtie"
6
6
  require "action_controller/railtie"
7
7
  require "action_view/railtie"
8
8
 
9
- # DETERMINATOR: We must explicitly require the routemaster backend we want to use
10
- require "routemaster/jobs/backends/sidekiq"
11
-
12
9
  Bundler.require(*Rails.groups)
13
10
 
14
11
  module DeterminatorExample
@@ -1,7 +1,7 @@
1
- require 'determinator/retrieve/routemaster'
1
+ require 'determinator/retrieve/dynaconf'
2
2
  require 'active_support/cache'
3
3
 
4
- retrieval = Determinator::Retrieve::Routemaster.new(discovery_url: 'https://flo.dev/')
4
+ retrieval = Determinator::Retrieve::Dynaconf.new(base_url: 'http://localhost:2345', service_name: 'determinator-rails')
5
5
  feature_cache = Determinator::Cache::FetchWrapper.new(
6
6
  ActiveSupport::Cache::MemoryStore.new(expires_in: 1.minute)
7
7
  )
@@ -1,5 +1,3 @@
1
- require 'routemaster/drain/cache_busting'
2
1
  Rails.application.routes.draw do
3
2
  root to: 'index#show'
4
- mount Routemaster::Drain::CacheBusting.new, at: ENV.fetch('ROUTEMASTER_CALLBACK_URL')
5
3
  end
data/lib/determinator.rb CHANGED
@@ -2,9 +2,8 @@ require 'determinator/version'
2
2
  require 'determinator/control'
3
3
  require 'determinator/feature'
4
4
  require 'determinator/target_group'
5
- require 'determinator/retrieve/routemaster'
6
- require 'determinator/retrieve/null_retriever'
7
5
  require 'determinator/cache/fetch_wrapper'
6
+ require 'determinator/serializers/json'
8
7
 
9
8
  module Determinator
10
9
  class << self
@@ -0,0 +1,46 @@
1
+ require 'faraday'
2
+
3
+ module Determinator
4
+ module Retrieve
5
+ # A class which loads features from Dynaconf server
6
+ class Dynaconf
7
+ # @param :base [String] The protocol, host and port for local Dynaconf server
8
+ # @param :service [String] The name of the service to be included in the User-Agent
9
+ # @param :client [String] Faraday client instance, defaults to a new instance
10
+ def initialize(base_url:, service_name:, client: default_client)
11
+ raise ArgumentError, "client must be a Faraday::Connection" unless client.is_a?(Faraday::Connection)
12
+
13
+ @base_url = base_url
14
+ @service_name = service_name
15
+ @client = client
16
+ end
17
+
18
+ def retrieve(feature_id)
19
+ response = get(feature_id)
20
+ Determinator::Serializers::JSON.load(response.body) if response.status == 200
21
+ rescue => e
22
+ Determinator.notice_error(e)
23
+ nil
24
+ end
25
+
26
+ private
27
+
28
+ def get(feature_id)
29
+ url = "#{@base_url}/scopes/florence-#{feature_id}/feature"
30
+
31
+ @client.get do |request|
32
+ request.url(url)
33
+ request['User-Agent'] = user_agent
34
+ end
35
+ end
36
+
37
+ def user_agent
38
+ @user_agent ||= "Determinator/Ruby v#{Determinator::VERSION} - #{@service_name}".freeze
39
+ end
40
+
41
+ def default_client
42
+ Faraday.new
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module Determinator
2
- VERSION = '1.2.0'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: determinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.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: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2019-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: routemaster-drain
14
+ name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '0'
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: '3.0'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.6'
125
+ - !ruby/object:Gem::Dependency
126
+ name: webmock
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description:
126
140
  email:
127
141
  - jp@deliveroo.co.uk
@@ -129,10 +143,11 @@ executables: []
129
143
  extensions: []
130
144
  extra_rdoc_files: []
131
145
  files:
146
+ - ".circleci/config.yml"
147
+ - ".circleci/config.yml.erb"
132
148
  - ".gitignore"
133
149
  - ".gitmodules"
134
150
  - ".rspec"
135
- - ".travis.yml"
136
151
  - CHANGELOG.md
137
152
  - CODE_OF_CONDUCT.md
138
153
  - Gemfile
@@ -142,7 +157,6 @@ files:
142
157
  - Rakefile
143
158
  - bin/console
144
159
  - bin/setup
145
- - circle.yml
146
160
  - determinator.gemspec
147
161
  - docs/background.md
148
162
  - docs/img/determinator.jpg
@@ -172,7 +186,6 @@ files:
172
186
  - examples/determinator-rails/config/initializers/new_framework_defaults.rb
173
187
  - examples/determinator-rails/config/initializers/wrap_parameters.rb
174
188
  - examples/determinator-rails/config/puma.rb
175
- - examples/determinator-rails/config/routemaster.rb
176
189
  - examples/determinator-rails/config/routes.rb
177
190
  - examples/determinator-rails/config/secrets.yml
178
191
  - examples/determinator-rails/public/favicon.ico
@@ -182,9 +195,9 @@ files:
182
195
  - lib/determinator/cache/fetch_wrapper.rb
183
196
  - lib/determinator/control.rb
184
197
  - lib/determinator/feature.rb
198
+ - lib/determinator/retrieve/dynaconf.rb
185
199
  - lib/determinator/retrieve/file.rb
186
200
  - lib/determinator/retrieve/null_retriever.rb
187
- - lib/determinator/retrieve/routemaster.rb
188
201
  - lib/determinator/serializers/json.rb
189
202
  - lib/determinator/target_group.rb
190
203
  - lib/determinator/version.rb
@@ -209,9 +222,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
222
  version: '0'
210
223
  requirements: []
211
224
  rubyforge_project:
212
- rubygems_version: 2.5.1
225
+ rubygems_version: 2.7.8
213
226
  signing_key:
214
227
  specification_version: 4
215
228
  summary: Determine which experiments and features a specific actor should see.
216
229
  test_files: []
217
- has_rdoc:
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.13.6
data/circle.yml DELETED
@@ -1,3 +0,0 @@
1
- checkout:
2
- post:
3
- - git submodule update --init
@@ -1,9 +0,0 @@
1
- #Sets up the routemaster client and subscribes to the 'features' topic
2
- Routemaster::Client.subscribe(
3
- topics: %w[
4
- features
5
- ],
6
- callback: ENV.fetch('ROUTEMASTER_CALLBACK_URL'),
7
- uuid: ENV.fetch('ROUTEMASTER_DRAIN_TOKENS'),
8
- max: ENV.fetch('ROUTEMASTER_DRAIN_BATCH_SIZE', 1).to_i
9
- )
@@ -1,53 +0,0 @@
1
- require 'uri'
2
- require 'routemaster/drain/caching'
3
- require 'routemaster/responses/hateoas_response'
4
- require 'determinator/serializers/json'
5
-
6
- module Determinator
7
- module Retrieve
8
- # A storage and retrieval engine for Determinator using routemaster-drain.
9
- #
10
- # To use this correctly you will need the following environment variables set to appropriate values
11
- # for your instance of Routemaster:
12
- #
13
- # ROUTEMASTER_CACHE_REDIS
14
- # ROUTEMASTER_CACHE_AUTH
15
- class Routemaster
16
- attr_reader :routemaster_app
17
-
18
- CALLBACK_PATH = (URI.parse(ENV['ROUTEMASTER_CALLBACK_URL']).path rescue '/events').freeze
19
-
20
- # @param :discovery_url [String] The bootstrap URL of the instance of Florence which defines Features.
21
- def initialize(discovery_url:)
22
- client = ::Routemaster::APIClient.new(
23
- response_class: ::Routemaster::Responses::HateoasResponse
24
- )
25
- @actor_service = client.discover(discovery_url)
26
- end
27
-
28
- # Retrieves and processes the feature that goes by the given name on this retrieval mechanism.
29
- # @return [Determinator::Feature,nil] The details of the specified feature
30
- def retrieve(name)
31
- obj = @actor_service.feature.show(name)
32
- Determinator::Serializers::JSON.load(obj.body.to_hash)
33
- rescue ::Routemaster::Errors::ResourceNotFound
34
- # Don't be noisy
35
- nil
36
- rescue => e
37
- Determinator.notice_error(e)
38
- nil
39
- end
40
-
41
- # Automatically configures the rails router to listen for Features with routemaster
42
- #
43
- # @param route_mapper [ActionDispatch::Routing::Mapper] The rails mapper, 'self' within the `routes.draw` block
44
- def configure_rails_router(route_mapper)
45
- route_mapper.mount routemaster_app, at: CALLBACK_PATH
46
- end
47
-
48
- def routemaster_app
49
- @routemaster_app ||= ::Routemaster::Drain::Caching.new
50
- end
51
- end
52
- end
53
- end