routemaster-drain 1.1.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
2
  SHA1:
3
- metadata.gz: a38994768fac0a952e0072791c9318b2c87912be
4
- data.tar.gz: 0e2acec86ae92448297a2ba916ef1ca61bdaefdb
3
+ metadata.gz: ced68b1893076a1cf8df7899e43afcf468487c74
4
+ data.tar.gz: 951f8e35d74922de878504e6487f64a689cea6f9
5
5
  SHA512:
6
- metadata.gz: 76718e5f07d9c5616e626eafcddb19323398f756f47f177fc4f0c34fa50e711346cd993bf71c4ec161cce3b4eedbe43868b71e8a89902ebacc91412de4d9bea7
7
- data.tar.gz: 0fa0392ec5962ffdc66023280e5503427609d9a2c3cefb827022d63acf4b29e1f55a3f838e7452f3bafa47f9dcb53f8555a596d401e469f0d538167fc0a89897
6
+ metadata.gz: 9d2be82bf2e1e3f4ad23687ee2a3b9d75ce1f49a9266f04e628da6608b4cdd18db86c06872f1685171d4bb61c98b465046ed75b84d6583dd53cc9edea02b1095
7
+ data.tar.gz: 12281b606df8070c1d97eee13c14ba75ee33fbbe3adf9c648fec2790e6cf7a2462fee51033c75e0828a16ddf05f4df03b3210c43e490361b7c1e647ef83114a4
data/.env.test CHANGED
@@ -3,4 +3,3 @@ ROUTEMASTER_DRAIN_REDIS=redis://localhost/13
3
3
  ROUTEMASTER_CACHE_REDIS=redis://localhost/12
4
4
  ROUTEMASTER_CACHE_AUTH=example.com:username:s3cr3t
5
5
  ROUTEMASTER_DRAIN_TOKENS=d3m0
6
-
data/.travis.yml CHANGED
@@ -5,6 +5,10 @@ services:
5
5
  rvm:
6
6
  - 2.2.5
7
7
  - 2.3.1
8
+ gemfile:
9
+ - gemfiles/rails_3.gemfile
10
+ - gemfiles/rails_4.gemfile
11
+ - gemfiles/rails_5.gemfile
8
12
  script:
9
13
  - bundle exec rspec
10
14
  - bundle exec codeclimate-test-reporter
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "rails-3" do
2
+ gem "rails", "3.2.14"
3
+ end
4
+
5
+ appraise "rails-4" do
6
+ gem "rails", "4.0.0"
7
+ end
8
+
9
+ appraise "rails-5" do
10
+ gem "rails", "5.0.0"
11
+ end
data/Gemfile CHANGED
@@ -9,13 +9,17 @@ gem 'psych', require: false
9
9
  # Used in builds and tests
10
10
  gem 'bundler', require: false
11
11
  gem 'rake', require: false
12
- gem 'guard-rspec', require: false
13
12
  gem 'webmock', require: false
14
- gem 'pry-byebug', require: false
15
13
  gem 'rack-test', require: false
16
14
  gem 'dotenv', require: false
17
15
  gem 'codeclimate-test-reporter', require: false
18
16
  gem 'simplecov'
19
- gem 'rspec'
20
17
  gem 'resque'
21
18
  gem 'sidekiq'
19
+
20
+ group :development, :test do
21
+ gem 'guard-rspec', require: false
22
+ gem 'pry-byebug', require: false
23
+ gem 'rspec'
24
+ gem 'appraisal'
25
+ end
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- routemaster-drain (1.1.0)
4
+ routemaster-drain (2.0.0)
5
5
  faraday (>= 0.9.0)
6
6
  faraday_middleware
7
7
  hashie
8
8
  net-http-persistent (< 3)
9
- rack (>= 1.6.2)
9
+ rack (>= 1.4.5)
10
10
  redis-namespace
11
11
  thread
12
12
  wisper (~> 1.6.1)
@@ -16,6 +16,10 @@ GEM
16
16
  specs:
17
17
  addressable (2.5.0)
18
18
  public_suffix (~> 2.0, >= 2.0.2)
19
+ appraisal (2.1.0)
20
+ bundler
21
+ rake
22
+ thor (>= 0.14.0)
19
23
  byebug (9.0.6)
20
24
  codeclimate-test-reporter (1.0.3)
21
25
  simplecov
@@ -68,17 +72,17 @@ GEM
68
72
  coderay (~> 1.1.0)
69
73
  method_source (~> 0.8.1)
70
74
  slop (~> 3.4)
71
- pry-byebug (3.4.1)
75
+ pry-byebug (3.4.2)
72
76
  byebug (~> 9.0)
73
77
  pry (~> 0.10)
74
78
  psych (2.2.1)
75
79
  public_suffix (2.0.4)
76
- rack (1.6.5)
80
+ rack (1.4.7)
77
81
  rack-protection (1.5.3)
78
82
  rack
79
83
  rack-test (0.6.3)
80
84
  rack (>= 1.0)
81
- rake (11.3.0)
85
+ rake (12.0.0)
82
86
  rb-fsevent (0.9.8)
83
87
  rb-inotify (0.9.7)
84
88
  ffi (>= 0.5.0)
@@ -117,8 +121,8 @@ GEM
117
121
  json (>= 1.8, < 3)
118
122
  simplecov-html (~> 0.10.0)
119
123
  simplecov-html (0.10.0)
120
- sinatra (1.4.7)
121
- rack (~> 1.5)
124
+ sinatra (1.4.6)
125
+ rack (~> 1.4)
122
126
  rack-protection (~> 1.4)
123
127
  tilt (>= 1.3, < 3)
124
128
  slop (3.6.0)
@@ -137,6 +141,7 @@ PLATFORMS
137
141
  ruby
138
142
 
139
143
  DEPENDENCIES
144
+ appraisal
140
145
  bundler
141
146
  codeclimate-test-reporter
142
147
  dotenv
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # routemaster-drain
2
2
 
3
3
  A Rack-based event receiver for the
4
- [Routemaster](https://github.com/mezis/routemaster) event bus.
4
+ [Routemaster](https://github.com/deliveroo/routemaster) event bus.
5
5
 
6
6
  [![Version](https://badge.fury.io/rb/routemaster-drain.svg)](https://rubygems.org/gems/routemaster-drain)
7
7
  &nbsp;
8
- [![Build](https://travis-ci.org/mezis/routemaster-drain.svg?branch=master)](https://travis-ci.org/mezis/routemaster-drain)
8
+ [![Build](https://travis-ci.org/deliveroo/routemaster-drain.svg?branch=master)](https://travis-ci.org/deliveroo/routemaster-drain)
9
9
  &nbsp;
10
10
  [![Code Climate](https://codeclimate.com/github/deliveroo/routemaster-drain/badges/gpa.svg)](https://codeclimate.com/github/deliveroo/routemaster-drain)
11
11
  [![Test Coverage](https://codeclimate.com/github/deliveroo/routemaster-drain/badges/coverage.svg)](https://codeclimate.com/github/deliveroo/routemaster-drain/coverage)
12
- [![Docs](http://img.shields.io/badge/API%20docs-rubydoc.info-blue.svg)](http://rubydoc.info/github/mezis/routemaster-drain/frames/file/README.md)
12
+ [![Docs](http://img.shields.io/badge/API%20docs-rubydoc.info-blue.svg)](http://rubydoc.info/github/deliveroo/routemaster-drain)
13
13
 
14
14
  `routemaster-drain` is a collection of Rack middleware to receive and
15
15
  parse Routemaster events, filter them, and preemptively cache the corresponding
@@ -28,6 +28,7 @@ combining middleware.
28
28
  - [Simply receive events from Routemaster](#simply-receive-events-from-routemaster)
29
29
  - [Receive change notifications without duplicates](#receive-change-notifications-without-duplicates)
30
30
  - [Cache data for all notified resources](#cache-data-for-all-notified-resources)
31
+ - [HTTP Client](#http-client)
31
32
  - [Internals](#internals)
32
33
  - [Dirty map](#dirty-map)
33
34
  - [Filter](#filter)
@@ -213,17 +214,65 @@ Note that `Cache#fget` is a future, so you can efficiently query many resources
213
214
  and have any `HTTP GET` requests (and cache queries) happen in parallel.
214
215
 
215
216
  See
216
- [rubydoc](http://rubydoc.info/github/mezis/routemaster-drain/Routemaster/Cache)
217
+ [rubydoc](http://rubydoc.info/github/deliveroo/routemaster-drain/Routemaster/Cache)
217
218
  for more details on `Cache`.
218
219
 
220
+ ## HTTP Client
221
+ The Drain is using a Faraday http client for communication between services. The client
222
+ comes with a convenient caching mechanism as a default and supports custom response materialization.
223
+ The Drain itself has the concept of "HATEOAS"(see below) response that provides a common way of addressing resources.
224
+
225
+ ** **In order for the client to discover the resources that you are interested in, you need to call the `#discover(service_url)`
226
+ method first**
227
+
228
+ Example:
229
+
230
+ ```ruby
231
+ require 'routemaster/fetcher'
232
+ require 'routemaster/responses/hateoas_response'
233
+
234
+ client = Routemaster::APIClient.new(response_class: Routemaster::Responses::HateoasResponse)
235
+
236
+ response = client.discover('https://identity.deliveroo.com.dev')
237
+ session_create_response = response.sessions.create(email: 'test@test.com', password: 'sup3rs3cr3t')
238
+ session_create_response.user.show(1)
239
+ ```
240
+
241
+ ### HATEOAS materialisation
242
+ The client comes with optional HATEOAS response capabilities. They are optional, because drain itself doesn't need to use the HATEOAS
243
+ response capabilities. Whenever the client is used outside of the drain it is **strongly** advised to be used with the HATEOAS response capabilities.
244
+ The HATEOAS response will materialize methods based on the keys found under the `_links` key on the payload. The semantics are the following:
245
+
246
+
247
+ ```ruby
248
+ # Given the following payload
249
+ {
250
+ "_links" : {
251
+ "users" : { "href" : "https://identity.deliveroo.com.dev/users" },
252
+ "user" : { "href" : "https://identity.deliveroo.com.dev/users/{id}", "templated" : true }
253
+ }
254
+ }
255
+
256
+ client = Routemaster::APIClient.new(response_class: Routemaster::Responses::HateoasResponse)
257
+ response = client.discover('https://identity.deliveroo.com.dev')
258
+
259
+ response.users.create(username: 'roo')
260
+ #=> HateoasResponse
261
+ response.users.index
262
+ #=> HateoasResponse
263
+ response.user.show(1)
264
+ #=> HateoasResponse
265
+ ```
266
+
267
+
219
268
 
220
269
  ## Internals
221
270
 
222
271
  The more elaborate drains are built with two components which can also be used
223
272
  independently,
224
- [`Dirty::Map`](http://rubydoc.info/github/mezis/routemaster-drain/Routemaster/Dirty/Map)
273
+ [`Dirty::Map`](http://rubydoc.info/github/deliveroo/routemaster-drain/Routemaster/Dirty/Map)
225
274
  and
226
- [`Dirty::Filter`](http://rubydoc.info/github/mezis/routemaster-drain/Routemaster/Dirty/Filter).
275
+ [`Dirty::Filter`](http://rubydoc.info/github/deliveroo/routemaster-drain/Routemaster/Dirty/Filter).
227
276
 
228
277
  ### Dirty map
229
278
 
@@ -235,22 +284,22 @@ A dirty map map gets _marked_ when an event about en entity gets processed that
235
284
  indicates a state change, and _swept_ to process those changes.
236
285
 
237
286
  Practically, instances of
238
- [`Routemaster::Dirty::Map`](http://rubydoc.info/github/mezis/routemaster-drain/Routemaster/Dirty/Map)
287
+ [`Routemaster::Dirty::Map`](http://rubydoc.info/github/deliveroo/routemaster-drain/Routemaster/Dirty/Map)
239
288
  will emit a `:dirty_entity` event when a URL is marked as dirty, and can be
240
289
  swept when an entity is "cleaned". If a URL is marked multiple times before
241
290
  being swept (e.g. for very volatile entities), the event will only by broadcast
242
291
  once.
243
292
 
244
293
  To sweep the map, you can for instance listen to this event and call
245
- [`#sweep_one`](http://rubydoc.info/github/mezis/routemaster-drain/Routemaster/Dirty/Map#sweep_one-instance_method).
294
+ [`#sweep_one`](http://rubydoc.info/github/deliveroo/routemaster-drain/Routemaster/Dirty/Map#sweep_one-instance_method).
246
295
 
247
296
  If you're not in a hurry and would rather run through batches you can call
248
- [`#sweep`](http://rubydoc.info/github/mezis/routemaster-drain/Routemaster/Dirty/Map#sweep-instance_method)
297
+ [`#sweep`](http://rubydoc.info/github/deliveroo/routemaster-drain/Routemaster/Dirty/Map#sweep-instance_method)
249
298
  which will yield URLs until it runs out of dirty resources.
250
299
 
251
300
  ### Filter
252
301
 
253
- [`Routemaster::Dirty::Filter`](http://rubydoc.info/github/mezis/routemaster-drain/Routemaster/Dirty/Filter) is a simple event filter
302
+ [`Routemaster::Dirty::Filter`](http://rubydoc.info/github/deliveroo/routemaster-drain/Routemaster/Dirty/Filter) is a simple event filter
254
303
  that performs reordering. It ignores events older than the latest known
255
304
  information on an entity.
256
305
 
@@ -261,7 +310,7 @@ as in `Receiver::Filter` for instance.
261
310
 
262
311
  ## Contributing
263
312
 
264
- 1. Fork it ( http://github.com/mezis/routemaster-drain/fork )
313
+ 1. Fork it ( http://github.com/deliveroo/routemaster-drain/fork )
265
314
  2. Create your feature branch (`git checkout -b my-new-feature`)
266
315
  3. Commit your changes (`git commit -am 'Add some feature'`)
267
316
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1,24 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "psych", :require => false
6
+ gem "bundler", :require => false
7
+ gem "rake", :require => false
8
+ gem "webmock", :require => false
9
+ gem "rack-test", :require => false
10
+ gem "dotenv", :require => false
11
+ gem "codeclimate-test-reporter", :require => false
12
+ gem "simplecov"
13
+ gem "resque"
14
+ gem "sidekiq"
15
+ gem "rails", "3.2.14"
16
+
17
+ group :development, :test do
18
+ gem "guard-rspec", :require => false
19
+ gem "pry-byebug", :require => false
20
+ gem "rspec"
21
+ gem "appraisal"
22
+ end
23
+
24
+ gemspec :path => "../"
@@ -0,0 +1,224 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ routemaster-drain (1.1.0)
5
+ faraday (>= 0.9.0)
6
+ faraday_middleware
7
+ hashie
8
+ net-http-persistent (< 3)
9
+ rack (>= 1.4.5)
10
+ redis-namespace
11
+ thread
12
+ wisper (~> 1.6.1)
13
+
14
+ GEM
15
+ remote: https://rubygems.org/
16
+ specs:
17
+ actionmailer (3.2.14)
18
+ actionpack (= 3.2.14)
19
+ mail (~> 2.5.4)
20
+ actionpack (3.2.14)
21
+ activemodel (= 3.2.14)
22
+ activesupport (= 3.2.14)
23
+ builder (~> 3.0.0)
24
+ erubis (~> 2.7.0)
25
+ journey (~> 1.0.4)
26
+ rack (~> 1.4.5)
27
+ rack-cache (~> 1.2)
28
+ rack-test (~> 0.6.1)
29
+ sprockets (~> 2.2.1)
30
+ activemodel (3.2.14)
31
+ activesupport (= 3.2.14)
32
+ builder (~> 3.0.0)
33
+ activerecord (3.2.14)
34
+ activeresource (3.2.14)
35
+ activemodel (= 3.2.14)
36
+ activesupport (= 3.2.14)
37
+ activesupport (3.2.14)
38
+ i18n (~> 0.6, >= 0.6.4)
39
+ multi_json (~> 1.0)
40
+ addressable (2.5.0)
41
+ public_suffix (~> 2.0, >= 2.0.2)
42
+ appraisal (2.1.0)
43
+ bundler
44
+ rake
45
+ thor (>= 0.14.0)
46
+ builder (3.0.4)
47
+ byebug (9.0.6)
48
+ codeclimate-test-reporter (1.0.3)
49
+ simplecov
50
+ coderay (1.1.1)
51
+ concurrent-ruby (1.0.2)
52
+ connection_pool (2.2.1)
53
+ crack (0.4.3)
54
+ safe_yaml (~> 1.0.0)
55
+ diff-lcs (1.2.5)
56
+ docile (1.1.5)
57
+ dotenv (2.1.1)
58
+ erubis (2.7.0)
59
+ faraday (0.10.0)
60
+ multipart-post (>= 1.2, < 3)
61
+ faraday_middleware (0.10.1)
62
+ faraday (>= 0.7.4, < 1.0)
63
+ ffi (1.9.14)
64
+ formatador (0.2.5)
65
+ guard (2.14.0)
66
+ formatador (>= 0.2.4)
67
+ listen (>= 2.7, < 4.0)
68
+ lumberjack (~> 1.0)
69
+ nenv (~> 0.1)
70
+ notiffany (~> 0.0)
71
+ pry (>= 0.9.12)
72
+ shellany (~> 0.0)
73
+ thor (>= 0.18.1)
74
+ guard-compat (1.2.1)
75
+ guard-rspec (4.7.3)
76
+ guard (~> 2.1)
77
+ guard-compat (~> 1.1)
78
+ rspec (>= 2.99.0, < 4.0)
79
+ hashdiff (0.3.1)
80
+ hashie (3.4.6)
81
+ hike (1.2.3)
82
+ i18n (0.7.0)
83
+ journey (1.0.4)
84
+ json (1.8.3)
85
+ listen (3.1.5)
86
+ rb-fsevent (~> 0.9, >= 0.9.4)
87
+ rb-inotify (~> 0.9, >= 0.9.7)
88
+ ruby_dep (~> 1.2)
89
+ lumberjack (1.0.10)
90
+ mail (2.5.4)
91
+ mime-types (~> 1.16)
92
+ treetop (~> 1.4.8)
93
+ method_source (0.8.2)
94
+ mime-types (1.25.1)
95
+ mono_logger (1.1.0)
96
+ multi_json (1.12.1)
97
+ multipart-post (2.0.0)
98
+ nenv (0.3.0)
99
+ net-http-persistent (2.9.4)
100
+ notiffany (0.1.1)
101
+ nenv (~> 0.1)
102
+ shellany (~> 0.0)
103
+ polyglot (0.3.5)
104
+ pry (0.10.4)
105
+ coderay (~> 1.1.0)
106
+ method_source (~> 0.8.1)
107
+ slop (~> 3.4)
108
+ pry-byebug (3.4.2)
109
+ byebug (~> 9.0)
110
+ pry (~> 0.10)
111
+ psych (2.2.1)
112
+ public_suffix (2.0.4)
113
+ rack (1.4.7)
114
+ rack-cache (1.6.1)
115
+ rack (>= 0.4)
116
+ rack-protection (1.5.3)
117
+ rack
118
+ rack-ssl (1.3.4)
119
+ rack
120
+ rack-test (0.6.3)
121
+ rack (>= 1.0)
122
+ rails (3.2.14)
123
+ actionmailer (= 3.2.14)
124
+ actionpack (= 3.2.14)
125
+ activerecord (= 3.2.14)
126
+ activeresource (= 3.2.14)
127
+ activesupport (= 3.2.14)
128
+ bundler (~> 1.0)
129
+ railties (= 3.2.14)
130
+ railties (3.2.14)
131
+ actionpack (= 3.2.14)
132
+ activesupport (= 3.2.14)
133
+ rack-ssl (~> 1.3.2)
134
+ rake (>= 0.8.7)
135
+ rdoc (~> 3.4)
136
+ thor (>= 0.14.6, < 2.0)
137
+ rake (12.0.0)
138
+ rb-fsevent (0.9.8)
139
+ rb-inotify (0.9.7)
140
+ ffi (>= 0.5.0)
141
+ rdoc (3.12.2)
142
+ json (~> 1.4)
143
+ redis (3.3.2)
144
+ redis-namespace (1.5.2)
145
+ redis (~> 3.0, >= 3.0.4)
146
+ resque (1.26.0)
147
+ mono_logger (~> 1.0)
148
+ multi_json (~> 1.0)
149
+ redis-namespace (~> 1.3)
150
+ sinatra (>= 0.9.2)
151
+ vegas (~> 0.1.2)
152
+ rspec (3.5.0)
153
+ rspec-core (~> 3.5.0)
154
+ rspec-expectations (~> 3.5.0)
155
+ rspec-mocks (~> 3.5.0)
156
+ rspec-core (3.5.4)
157
+ rspec-support (~> 3.5.0)
158
+ rspec-expectations (3.5.0)
159
+ diff-lcs (>= 1.2.0, < 2.0)
160
+ rspec-support (~> 3.5.0)
161
+ rspec-mocks (3.5.0)
162
+ diff-lcs (>= 1.2.0, < 2.0)
163
+ rspec-support (~> 3.5.0)
164
+ rspec-support (3.5.0)
165
+ ruby_dep (1.5.0)
166
+ safe_yaml (1.0.4)
167
+ shellany (0.0.1)
168
+ sidekiq (4.2.7)
169
+ concurrent-ruby (~> 1.0)
170
+ connection_pool (~> 2.2, >= 2.2.0)
171
+ rack-protection (>= 1.5.0)
172
+ redis (~> 3.2, >= 3.2.1)
173
+ simplecov (0.12.0)
174
+ docile (~> 1.1.0)
175
+ json (>= 1.8, < 3)
176
+ simplecov-html (~> 0.10.0)
177
+ simplecov-html (0.10.0)
178
+ sinatra (1.4.6)
179
+ rack (~> 1.4)
180
+ rack-protection (~> 1.4)
181
+ tilt (>= 1.3, < 3)
182
+ slop (3.6.0)
183
+ sprockets (2.2.3)
184
+ hike (~> 1.2)
185
+ multi_json (~> 1.0)
186
+ rack (~> 1.0)
187
+ tilt (~> 1.1, != 1.3.0)
188
+ thor (0.19.4)
189
+ thread (0.2.2)
190
+ tilt (1.4.1)
191
+ treetop (1.4.15)
192
+ polyglot
193
+ polyglot (>= 0.3.1)
194
+ vegas (0.1.11)
195
+ rack (>= 1.0.0)
196
+ webmock (2.3.1)
197
+ addressable (>= 2.3.6)
198
+ crack (>= 0.3.2)
199
+ hashdiff
200
+ wisper (1.6.1)
201
+
202
+ PLATFORMS
203
+ ruby
204
+
205
+ DEPENDENCIES
206
+ appraisal
207
+ bundler
208
+ codeclimate-test-reporter
209
+ dotenv
210
+ guard-rspec
211
+ pry-byebug
212
+ psych
213
+ rack-test
214
+ rails (= 3.2.14)
215
+ rake
216
+ resque
217
+ routemaster-drain!
218
+ rspec
219
+ sidekiq
220
+ simplecov
221
+ webmock
222
+
223
+ BUNDLED WITH
224
+ 1.13.6
@@ -0,0 +1,24 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "psych", :require => false
6
+ gem "bundler", :require => false
7
+ gem "rake", :require => false
8
+ gem "webmock", :require => false
9
+ gem "rack-test", :require => false
10
+ gem "dotenv", :require => false
11
+ gem "codeclimate-test-reporter", :require => false
12
+ gem "simplecov"
13
+ gem "resque"
14
+ gem "sidekiq"
15
+ gem "rails", "4.0.0"
16
+
17
+ group :development, :test do
18
+ gem "guard-rspec", :require => false
19
+ gem "pry-byebug", :require => false
20
+ gem "rspec"
21
+ gem "appraisal"
22
+ end
23
+
24
+ gemspec :path => "../"