routemaster-client 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -2
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +23 -23
- data/README.md +16 -46
- data/routemaster/client.rb +49 -19
- data/routemaster/client/backends/sidekiq/worker.rb +6 -5
- data/routemaster/client/connection.rb +4 -3
- data/routemaster/client/version.rb +1 -1
- data/routemaster/receiver.rb +4 -5
- data/spec/client_spec.rb +99 -89
- data/spec/receiver_spec.rb +0 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd1e1f24e8d625dbdd9824f986e1c3fe57107575
|
4
|
+
data.tar.gz: ea838ffeb71a05fca351a41b00075bad143ec31f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f08a91701b5d8984fe51fe40f0c9c659647f0648a9ef432422e471b821c5c4fd7092efe4db5a8cf5e2d030438ab4f67c92e89669d6a509ae47531d02254c6b6
|
7
|
+
data.tar.gz: bbc44b01fed6ecb14932da518d67bbff9c9b38823bc8a98cf77de6f124d9868c496eea1f4f7d26924e320544e793cebf61609846910eaf52a024467cdeb09ae7
|
data/.travis.yml
CHANGED
@@ -3,9 +3,14 @@ cache: bundler
|
|
3
3
|
rvm:
|
4
4
|
- 2.2.5
|
5
5
|
- 2.3.1
|
6
|
+
- 2.4.0
|
7
|
+
- ruby-head
|
6
8
|
script:
|
7
|
-
- bundle exec rspec
|
8
|
-
- bundle exec codeclimate-test-reporter
|
9
|
+
- bundle exec rspec
|
10
|
+
- bundle exec codeclimate-test-reporter
|
9
11
|
addons:
|
10
12
|
code_climate:
|
11
13
|
repo_token: b1d80c686f42ee5eb66895c4b0ac5c0d978e964d4700eae35aa0138f5a650c02
|
14
|
+
matrix:
|
15
|
+
allow_failures:
|
16
|
+
- rvm: ruby-head
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
routemaster-client (3.
|
4
|
+
routemaster-client (3.1.0)
|
5
5
|
faraday (>= 0.9.0)
|
6
6
|
oj (~> 2.17)
|
7
7
|
typhoeus (~> 1.1)
|
@@ -13,22 +13,22 @@ GEM
|
|
13
13
|
addressable (2.5.0)
|
14
14
|
public_suffix (~> 2.0, >= 2.0.2)
|
15
15
|
byebug (9.0.6)
|
16
|
-
codeclimate-test-reporter (1.0.
|
17
|
-
simplecov
|
16
|
+
codeclimate-test-reporter (1.0.8)
|
17
|
+
simplecov (<= 0.13)
|
18
18
|
coderay (1.1.1)
|
19
|
-
concurrent-ruby (1.0.
|
19
|
+
concurrent-ruby (1.0.5)
|
20
20
|
connection_pool (2.2.1)
|
21
21
|
crack (0.4.3)
|
22
22
|
safe_yaml (~> 1.0.0)
|
23
|
-
diff-lcs (1.
|
23
|
+
diff-lcs (1.3)
|
24
24
|
docile (1.1.5)
|
25
25
|
ethon (0.10.1)
|
26
26
|
ffi (>= 1.3.0)
|
27
|
-
faraday (0.
|
27
|
+
faraday (0.11.0)
|
28
28
|
multipart-post (>= 1.2, < 3)
|
29
|
-
ffi (1.9.
|
29
|
+
ffi (1.9.18)
|
30
30
|
formatador (0.2.5)
|
31
|
-
guard (2.14.
|
31
|
+
guard (2.14.1)
|
32
32
|
formatador (>= 0.2.4)
|
33
33
|
listen (>= 2.7, < 4.0)
|
34
34
|
lumberjack (~> 1.0)
|
@@ -42,39 +42,39 @@ GEM
|
|
42
42
|
guard (~> 2.1)
|
43
43
|
guard-compat (~> 1.1)
|
44
44
|
rspec (>= 2.99.0, < 4.0)
|
45
|
-
hashdiff (0.3.
|
46
|
-
json (2.0.
|
45
|
+
hashdiff (0.3.2)
|
46
|
+
json (2.0.3)
|
47
47
|
listen (3.1.5)
|
48
48
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
49
49
|
rb-inotify (~> 0.9, >= 0.9.7)
|
50
50
|
ruby_dep (~> 1.2)
|
51
|
-
lumberjack (1.0.
|
51
|
+
lumberjack (1.0.11)
|
52
52
|
method_source (0.8.2)
|
53
53
|
multipart-post (2.0.0)
|
54
54
|
nenv (0.3.0)
|
55
55
|
notiffany (0.1.1)
|
56
56
|
nenv (~> 0.1)
|
57
57
|
shellany (~> 0.0)
|
58
|
-
oj (2.18.
|
58
|
+
oj (2.18.3)
|
59
59
|
pry (0.10.4)
|
60
60
|
coderay (~> 1.1.0)
|
61
61
|
method_source (~> 0.8.1)
|
62
62
|
slop (~> 3.4)
|
63
|
-
pry-byebug (3.4.
|
63
|
+
pry-byebug (3.4.2)
|
64
64
|
byebug (~> 9.0)
|
65
65
|
pry (~> 0.10)
|
66
|
-
psych (2.2.
|
67
|
-
public_suffix (2.0.
|
66
|
+
psych (2.2.4)
|
67
|
+
public_suffix (2.0.5)
|
68
68
|
rack (2.0.1)
|
69
69
|
rack-protection (1.5.3)
|
70
70
|
rack
|
71
71
|
rack-test (0.6.3)
|
72
72
|
rack (>= 1.0)
|
73
|
-
rake (
|
73
|
+
rake (12.0.0)
|
74
74
|
rb-fsevent (0.9.8)
|
75
|
-
rb-inotify (0.9.
|
75
|
+
rb-inotify (0.9.8)
|
76
76
|
ffi (>= 0.5.0)
|
77
|
-
redis (3.3.
|
77
|
+
redis (3.3.3)
|
78
78
|
rspec (3.5.0)
|
79
79
|
rspec-core (~> 3.5.0)
|
80
80
|
rspec-expectations (~> 3.5.0)
|
@@ -91,12 +91,12 @@ GEM
|
|
91
91
|
ruby_dep (1.5.0)
|
92
92
|
safe_yaml (1.0.4)
|
93
93
|
shellany (0.0.1)
|
94
|
-
sidekiq (4.2.
|
94
|
+
sidekiq (4.2.10)
|
95
95
|
concurrent-ruby (~> 1.0)
|
96
96
|
connection_pool (~> 2.2, >= 2.2.0)
|
97
|
-
rack-protection (
|
97
|
+
rack-protection (>= 1.5.0)
|
98
98
|
redis (~> 3.2, >= 3.2.1)
|
99
|
-
simplecov (0.
|
99
|
+
simplecov (0.13.0)
|
100
100
|
docile (~> 1.1.0)
|
101
101
|
json (>= 1.8, < 3)
|
102
102
|
simplecov-html (~> 0.10.0)
|
@@ -105,7 +105,7 @@ GEM
|
|
105
105
|
thor (0.19.4)
|
106
106
|
typhoeus (1.1.2)
|
107
107
|
ethon (>= 0.9.0)
|
108
|
-
webmock (2.3.
|
108
|
+
webmock (2.3.2)
|
109
109
|
addressable (>= 2.3.6)
|
110
110
|
crack (>= 0.3.2)
|
111
111
|
hashdiff
|
@@ -128,4 +128,4 @@ DEPENDENCIES
|
|
128
128
|
webmock
|
129
129
|
|
130
130
|
BUNDLED WITH
|
131
|
-
1.
|
131
|
+
1.14.5
|
data/README.md
CHANGED
@@ -26,18 +26,9 @@ Or install it yourself as:
|
|
26
26
|
```ruby
|
27
27
|
require 'routemaster/client'
|
28
28
|
Routemaster::Client.configure do |config|
|
29
|
-
config.url = 'https://
|
30
|
-
config.uuid = 'demo'
|
31
|
-
|
32
|
-
```
|
33
|
-
|
34
|
-
You can also specify a timeout value in seconds if you like with the ```timeout``` option.
|
35
|
-
|
36
|
-
```ruby
|
37
|
-
Routemaster::Client.configure do |config|
|
38
|
-
config.url = 'https://bs.example.com'
|
39
|
-
config.uuid = 'demo'
|
40
|
-
config.timeout = 2
|
29
|
+
config.url = 'https://bus.example.com'
|
30
|
+
config.uuid = 'demo' # HTTP Basic token used to talk to the bus
|
31
|
+
config.timeout = 2 # in seconds
|
41
32
|
end
|
42
33
|
```
|
43
34
|
|
@@ -45,9 +36,7 @@ If you are using Sidekiq in your project, you can specify the usage of a Sidekiq
|
|
45
36
|
|
46
37
|
```ruby
|
47
38
|
Routemaster::Client.configure do |config|
|
48
|
-
|
49
|
-
config.uuid = 'demo'
|
50
|
-
config.timeout = 2
|
39
|
+
# ...
|
51
40
|
config.async_backend = Routemaster::Client::Backends::Sidekiq.configure do |sidekiq|
|
52
41
|
sidekiq.queue = :realtime
|
53
42
|
sidekiq.retry = false
|
@@ -74,18 +63,23 @@ A timestamp argument may be passed (it will be set by the bus automatically
|
|
74
63
|
otherwise); it must be an integer number of milliseconds since the UNIX Epoch:
|
75
64
|
|
76
65
|
```ruby
|
77
|
-
Routemaster::Client.created('widgets', 'https://app.example.com/widgets/1', 1473080555409)
|
66
|
+
Routemaster::Client.created('widgets', 'https://app.example.com/widgets/1', t: 1473080555409)
|
78
67
|
```
|
79
68
|
|
80
|
-
|
81
|
-
|
82
|
-
|
69
|
+
You can also push events asynchronously if you have configured a backend that
|
70
|
+
supports this (otherwise an error will be raised):
|
71
|
+
|
83
72
|
```ruby
|
84
|
-
|
73
|
+
Routemaster::Client.updated('widgets', 'https://app.example.com/widgets/2', async: true)
|
85
74
|
```
|
86
75
|
|
87
|
-
|
88
|
-
|
76
|
+
A data payload can be sent alongside the event. It is strongly discouraged to do
|
77
|
+
this except extrame circumstances (particularly as schema migrations become very
|
78
|
+
painful):
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
Routemaster::Client.created('cats', 'https://app.example.com/cats/42', data: { 'color' => 'teal' })
|
82
|
+
```
|
89
83
|
|
90
84
|
**Subscribe** to be notified about `widgets` and `kitten` at most 60 seconds after
|
91
85
|
events, in batches of at most 500 events, to a given callback URL:
|
@@ -100,30 +94,6 @@ Routemaster::Client.subscribe(
|
|
100
94
|
```
|
101
95
|
|
102
96
|
|
103
|
-
**Receive** events at path `/events` using a Rack middleware:
|
104
|
-
|
105
|
-
```ruby
|
106
|
-
require 'routemaster/receiver'
|
107
|
-
|
108
|
-
class Listener
|
109
|
-
def on_events_received(batch)
|
110
|
-
batch.each do |event|
|
111
|
-
puts event['url']
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
Wisper.subscribe(Listener.new, :prefix => true)
|
117
|
-
|
118
|
-
use Routemaster::Receiver, {
|
119
|
-
path: '/events',
|
120
|
-
uuid: 'demo'
|
121
|
-
}
|
122
|
-
```
|
123
|
-
|
124
|
-
This relies on the excellent event bus from the [wisper
|
125
|
-
gem](https://github.com/krisleech/wisper#wisper).
|
126
|
-
|
127
97
|
**Unsubscribe** from a single topic:
|
128
98
|
|
129
99
|
```ruby
|
data/routemaster/client.rb
CHANGED
@@ -30,36 +30,48 @@ module Routemaster
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def created(topic, callback, timestamp = nil)
|
34
|
-
|
33
|
+
def created(topic, callback, timestamp = nil, t: nil, async: false, data: nil)
|
34
|
+
_warn_timestamp_deprecation(timestamp)
|
35
|
+
_send_event('create', topic, callback, t: t || timestamp, async: async, data: data)
|
35
36
|
end
|
36
37
|
|
37
|
-
def created_async(topic, callback, timestamp = nil)
|
38
|
-
|
38
|
+
def created_async(topic, callback, timestamp = nil, t: nil, data: nil)
|
39
|
+
_warn_timestamp_deprecation(timestamp)
|
40
|
+
_warn_async_deprecation
|
41
|
+
_send_event('create', topic, callback, t: t || timestamp, async: true, data: data)
|
39
42
|
end
|
40
43
|
|
41
|
-
def updated(topic, callback, timestamp = nil)
|
42
|
-
|
44
|
+
def updated(topic, callback, timestamp = nil, t: nil, async: false, data: nil)
|
45
|
+
_warn_timestamp_deprecation(timestamp)
|
46
|
+
_send_event('update', topic, callback, t: t || timestamp, async: async, data: data)
|
43
47
|
end
|
44
48
|
|
45
|
-
def updated_async(topic, callback, timestamp = nil)
|
46
|
-
|
49
|
+
def updated_async(topic, callback, timestamp = nil, t: nil, data: nil)
|
50
|
+
_warn_timestamp_deprecation(timestamp)
|
51
|
+
_warn_async_deprecation
|
52
|
+
_send_event('update', topic, callback, t: t || timestamp, async: true, data: data)
|
47
53
|
end
|
48
54
|
|
49
|
-
def deleted(topic, callback, timestamp = nil)
|
50
|
-
|
55
|
+
def deleted(topic, callback, timestamp = nil, t: nil, async: false, data: nil)
|
56
|
+
_warn_timestamp_deprecation(timestamp)
|
57
|
+
_send_event('delete', topic, callback, t: t || timestamp, async: async, data: data)
|
51
58
|
end
|
52
59
|
|
53
|
-
def deleted_async(topic, callback, timestamp = nil)
|
54
|
-
|
60
|
+
def deleted_async(topic, callback, timestamp = nil, t: nil, data: nil)
|
61
|
+
_warn_timestamp_deprecation(timestamp)
|
62
|
+
_warn_async_deprecation
|
63
|
+
_send_event('delete', topic, callback, t: t || timestamp, async: true, data: data)
|
55
64
|
end
|
56
65
|
|
57
|
-
def noop(topic, callback, timestamp = nil)
|
58
|
-
|
66
|
+
def noop(topic, callback, timestamp = nil, t: nil, async: false, data: nil)
|
67
|
+
_warn_timestamp_deprecation(timestamp)
|
68
|
+
_send_event('noop', topic, callback, t: t || timestamp, async: async, data: data)
|
59
69
|
end
|
60
70
|
|
61
|
-
def noop_async(topic, callback, timestamp = nil)
|
62
|
-
|
71
|
+
def noop_async(topic, callback, timestamp = nil, t: nil, data: nil)
|
72
|
+
_warn_timestamp_deprecation(timestamp)
|
73
|
+
_warn_async_deprecation
|
74
|
+
_send_event('noop', topic, callback, t: t || timestamp, async: true, data: data)
|
63
75
|
end
|
64
76
|
|
65
77
|
def subscribe(topics:, callback:, **options)
|
@@ -165,13 +177,20 @@ module Routemaster
|
|
165
177
|
end
|
166
178
|
end
|
167
179
|
|
168
|
-
def
|
180
|
+
def _assert_valid_data(value)
|
181
|
+
!! Oj.dump(value, mode: :strict)
|
182
|
+
rescue TypeError => e
|
183
|
+
raise InvalidArgumentError, e
|
184
|
+
end
|
185
|
+
|
186
|
+
def _send_event(event, topic, callback, t: nil, async: false, data: nil)
|
169
187
|
_assert_valid_url!(callback)
|
170
188
|
_assert_valid_topic!(topic)
|
171
|
-
_assert_valid_timestamp!(
|
189
|
+
_assert_valid_timestamp!(t) if t
|
190
|
+
_assert_valid_data(data) if data
|
172
191
|
|
173
192
|
backend = async ? async_backend : _synchronous_backend
|
174
|
-
backend.send_event(event, topic, callback,
|
193
|
+
backend.send_event(event, topic, callback, t: t, data: data)
|
175
194
|
end
|
176
195
|
|
177
196
|
def _check_pulse!
|
@@ -180,6 +199,17 @@ module Routemaster
|
|
180
199
|
end
|
181
200
|
end
|
182
201
|
|
202
|
+
def _warn_async_deprecation
|
203
|
+
warn 'routemaster-client: The _*_async event-sending methods are deprecated. Use async: true instead.'
|
204
|
+
warn "(in #{caller(2,1).first})"
|
205
|
+
end
|
206
|
+
|
207
|
+
def _warn_timestamp_deprecation(value)
|
208
|
+
return if value.nil?
|
209
|
+
warn 'routemaster-client: Passing timestamps as positional parameters is deprecated. Use the t: key instead.'
|
210
|
+
warn "(in #{caller(2,1).first})"
|
211
|
+
end
|
212
|
+
|
183
213
|
private :async_backend, :lazy
|
184
214
|
end
|
185
215
|
end
|
@@ -6,12 +6,13 @@ module Routemaster
|
|
6
6
|
class Sidekiq
|
7
7
|
class Worker
|
8
8
|
include ::Sidekiq::Worker
|
9
|
-
extend Forwardable
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def perform(*args)
|
11
|
+
# Sidekiq does not have transparent argument serialization.
|
12
|
+
# This extracts the options so they can be passed on properly.
|
13
|
+
options = args.last.kind_of?(Hash) ? args.pop.symbolize_keys : {}
|
14
|
+
Routemaster::Client::Connection.send_event(*args, **options)
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -22,12 +22,13 @@ module Routemaster
|
|
22
22
|
_conn.send(method, path, &block)
|
23
23
|
end
|
24
24
|
|
25
|
-
def send_event(event, topic, callback,
|
26
|
-
|
25
|
+
def send_event(event, topic, callback, t: nil, data: nil)
|
26
|
+
payload = { 'type' => event, 'url' => callback, 'timestamp' => t }
|
27
|
+
payload['data'] = data unless data.nil?
|
27
28
|
|
28
29
|
response = post("/topics/#{topic}") do |r|
|
29
30
|
r.headers['Content-Type'] = 'application/json'
|
30
|
-
r.body = Oj.dump(
|
31
|
+
r.body = Oj.dump(payload, mode: :strict)
|
31
32
|
end
|
32
33
|
fail "event rejected (#{response.status})" unless response.success?
|
33
34
|
|
data/routemaster/receiver.rb
CHANGED
@@ -8,14 +8,13 @@ module Routemaster
|
|
8
8
|
include Wisper::Publisher
|
9
9
|
|
10
10
|
def initialize(app, options = {})
|
11
|
+
warn 'Routemaster::Receiver is deprecated, use Routemaster::Drain::Basic instead'
|
12
|
+
warn "(at #{caller(2,1).first})"
|
13
|
+
|
11
14
|
@app = app
|
12
15
|
@path = options[:path]
|
13
16
|
@uuid = options[:uuid]
|
14
|
-
|
15
|
-
if options[:handler]
|
16
|
-
warn 'the :handler option is deprecated, listen to the :events_received event instead'
|
17
|
-
@handler = options[:handler]
|
18
|
-
end
|
17
|
+
@handler = options[:handler] if options[:handler]
|
19
18
|
end
|
20
19
|
|
21
20
|
def call(env)
|
data/spec/client_spec.rb
CHANGED
@@ -61,7 +61,7 @@ describe Routemaster::Client do
|
|
61
61
|
shared_examples 'an unconfigured async event sender' do
|
62
62
|
let(:callback) { 'https://app.example.com/widgets/123' }
|
63
63
|
let(:topic) { 'widgets' }
|
64
|
-
let(:perform) { subject.send(method, topic, callback) }
|
64
|
+
let(:perform) { subject.send(method, topic, callback, **flags) }
|
65
65
|
let(:http_status) { nil }
|
66
66
|
|
67
67
|
it 'raises an error' do
|
@@ -72,7 +72,7 @@ describe Routemaster::Client do
|
|
72
72
|
shared_examples 'an event sender' do
|
73
73
|
let(:callback) { 'https://app.example.com/widgets/123' }
|
74
74
|
let(:topic) { 'widgets' }
|
75
|
-
let(:perform) { subject.send(event, topic, callback) }
|
75
|
+
let(:perform) { subject.send(event, topic, callback, **flags) }
|
76
76
|
let(:http_status) { nil }
|
77
77
|
|
78
78
|
before do
|
@@ -136,7 +136,7 @@ describe Routemaster::Client do
|
|
136
136
|
|
137
137
|
context 'with explicit timestamp' do
|
138
138
|
let(:timestamp) { (Time.now.to_f * 1e3).to_i }
|
139
|
-
let(:perform) { subject.send(event, topic, callback, timestamp) }
|
139
|
+
let(:perform) { subject.send(event, topic, callback, t: timestamp) }
|
140
140
|
|
141
141
|
before do
|
142
142
|
@stub = stub_request(:post, 'https://@bus.example.com/topics/widgets').
|
@@ -168,106 +168,116 @@ describe Routemaster::Client do
|
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
171
|
-
end
|
172
171
|
|
173
|
-
|
174
|
-
|
175
|
-
let(:
|
176
|
-
|
177
|
-
end
|
172
|
+
context 'with a data payload' do
|
173
|
+
let(:timestamp) { (Time.now.to_f * 1e3).to_i }
|
174
|
+
let(:perform) { subject.send(event, topic, callback, data: data) }
|
175
|
+
let(:data) {{ 'foo' => 'bar' }}
|
178
176
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
177
|
+
before do
|
178
|
+
@stub = stub_request(:post, 'https://@bus.example.com/topics/widgets').
|
179
|
+
with(
|
180
|
+
body: hash_including(data: data),
|
181
|
+
basic_auth: [options[:uuid], 'x'],
|
182
|
+
).
|
183
|
+
to_return(status: 200)
|
184
|
+
end
|
183
185
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
186
|
+
it 'sends the event' do
|
187
|
+
perform
|
188
|
+
expect(@stub).to have_been_requested
|
189
|
+
end
|
188
190
|
|
189
|
-
|
190
|
-
|
191
|
-
it_behaves_like 'an unconfigured async event sender'
|
192
|
-
end
|
191
|
+
context 'with non-serializable data' do
|
192
|
+
let(:data) { [:foo, 'bar'] }
|
193
193
|
|
194
|
-
|
195
|
-
|
196
|
-
|
194
|
+
it 'fails' do
|
195
|
+
expect { perform }.to raise_error(Routemaster::Client::InvalidArgumentError)
|
196
|
+
end
|
197
|
+
end
|
197
198
|
end
|
199
|
+
end
|
198
200
|
|
199
|
-
|
200
|
-
|
201
|
-
|
201
|
+
context 'without a background worker specified' do
|
202
|
+
context 'with default flags' do
|
203
|
+
%w[created updated deleted noop].each do |m|
|
204
|
+
describe "##{m}" do
|
205
|
+
let(:event) { m.to_sym }
|
206
|
+
let(:flags) { {} }
|
207
|
+
it_behaves_like 'an event sender'
|
208
|
+
end
|
209
|
+
end
|
202
210
|
end
|
203
211
|
|
204
|
-
|
205
|
-
|
206
|
-
|
212
|
+
context 'with the :async flag' do
|
213
|
+
%w[created updated deleted noop].each do |m|
|
214
|
+
describe "##{m}" do
|
215
|
+
let(:method) { m }
|
216
|
+
let(:flags) { { async: true } }
|
217
|
+
it_behaves_like 'an unconfigured async event sender'
|
218
|
+
end
|
219
|
+
end
|
207
220
|
end
|
208
221
|
|
209
|
-
describe '
|
210
|
-
|
211
|
-
|
222
|
+
describe 'deprecated *_async methods' do
|
223
|
+
%w[created updated deleted noop].each do |m|
|
224
|
+
describe "##{m}_async" do
|
225
|
+
let(:method) { "#{m}_async" }
|
226
|
+
let(:flags) { {} }
|
227
|
+
it_behaves_like 'an unconfigured async event sender'
|
228
|
+
end
|
229
|
+
end
|
212
230
|
end
|
213
231
|
end
|
214
232
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
it_behaves_like 'an event sender'
|
264
|
-
end
|
265
|
-
|
266
|
-
describe '#noop_async' do
|
267
|
-
let(:event) { 'noop_async' }
|
268
|
-
it_behaves_like 'an event sender'
|
269
|
-
end
|
270
|
-
end
|
233
|
+
context 'with the sidekiq async back end configured' do
|
234
|
+
reset_sidekiq_config_between_tests!
|
235
|
+
|
236
|
+
before do
|
237
|
+
options[:async_backend] = Routemaster::Client::Backends::Sidekiq.configure do |config|
|
238
|
+
config.queue = :realtime
|
239
|
+
config.retry = true
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
around do |example|
|
244
|
+
Sidekiq::Testing.inline! do
|
245
|
+
example.run
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
context 'with default options' do
|
250
|
+
let(:flags) { {} }
|
251
|
+
|
252
|
+
%w[created updated deleted noop].each do |m|
|
253
|
+
describe "##{m}" do
|
254
|
+
let(:event) { m }
|
255
|
+
it_behaves_like 'an event sender'
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
context 'with :async option' do
|
261
|
+
let(:flags) { { async: true } }
|
262
|
+
|
263
|
+
%w[created updated deleted noop].each do |m|
|
264
|
+
describe "##{m}" do
|
265
|
+
let(:event) { m }
|
266
|
+
it_behaves_like 'an event sender'
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe 'deprecated *_async methods' do
|
272
|
+
%w[created updated deleted noop].each do |m|
|
273
|
+
describe "##{m}_async" do
|
274
|
+
let(:event) { "#{m}_async" }
|
275
|
+
let(:flags) { {} }
|
276
|
+
it_behaves_like 'an event sender'
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
271
281
|
|
272
282
|
describe '#subscribe' do
|
273
283
|
let(:perform) { subject.subscribe(subscribe_options) }
|
data/spec/receiver_spec.rb
CHANGED
@@ -77,11 +77,6 @@ describe Routemaster::Receiver do
|
|
77
77
|
expect(handler).to receive(:on_events).exactly(3).times
|
78
78
|
3.times { perform }
|
79
79
|
end
|
80
|
-
|
81
|
-
it 'warns about deprecation' do
|
82
|
-
expect_any_instance_of(described_class).to receive(:warn).with(/deprecated/)
|
83
|
-
app
|
84
|
-
end
|
85
80
|
end
|
86
81
|
|
87
82
|
context 'with a listener' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routemaster-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Letessier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- ".rspec"
|
79
79
|
- ".ruby-version"
|
80
80
|
- ".travis.yml"
|
81
|
+
- CHANGELOG.md
|
81
82
|
- Gemfile
|
82
83
|
- Gemfile.lock
|
83
84
|
- Guardfile
|