pebbles-river 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pebbles/river/river.rb +3 -0
- data/lib/pebbles/river/version.rb +1 -1
- data/lib/pebbles/river/worker.rb +4 -2
- data/spec/lib/river_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15f6450fc13837c238c851ec2601a22014af4c9
|
4
|
+
data.tar.gz: 0ae589054e73a758e3bd7192ff48aa0bf4c58914
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f33c6d5cf3c3fd673070f9ab7c3c4f7b60e94759f4be2bde99ab70e96b83405afc542b11ec55b084aa5240468f53769fa66d2b1853e5534c587a159237b01f1
|
7
|
+
data.tar.gz: e838b8e2d6ec8c8d75dd759f6687af5c92f20d4e2fd0967c7c902479d48fd440fdacc0d66674a1387c22f040c39702a87cb48516040e753bc7c5c0b0721d8c57
|
data/lib/pebbles/river/river.rb
CHANGED
@@ -7,12 +7,14 @@ module Pebbles
|
|
7
7
|
attr_reader :exchange
|
8
8
|
attr_reader :session
|
9
9
|
attr_reader :channel
|
10
|
+
attr_reader :prefetch
|
10
11
|
|
11
12
|
def initialize(options = {})
|
12
13
|
options = {environment: options} if options.is_a?(String) # Backwards compatibility
|
13
14
|
|
14
15
|
@environment = (options[:environment] || ENV['RACK_ENV'] || 'development').dup.freeze
|
15
16
|
@last_connect_attempt = nil
|
17
|
+
@prefetch = options[:prefetch]
|
16
18
|
end
|
17
19
|
|
18
20
|
def connected?
|
@@ -27,6 +29,7 @@ module Pebbles
|
|
27
29
|
session.start
|
28
30
|
|
29
31
|
channel = session.create_channel
|
32
|
+
channel.prefetch(@prefetch) if @prefetch
|
30
33
|
|
31
34
|
exchange = channel.exchange(exchange_name, EXCHANGE_OPTIONS.dup)
|
32
35
|
|
data/lib/pebbles/river/worker.rb
CHANGED
@@ -25,6 +25,7 @@ module Pebbles
|
|
25
25
|
# is automatically acked unless the handler returns false or the handler
|
26
26
|
# raises an exception, in which case it's nacked. If false, the handler
|
27
27
|
# must do the ack/nacking. Defaults to true.
|
28
|
+
# * `prefetch`: If specified, sets channel's prefetch count.
|
28
29
|
#
|
29
30
|
# The handler must implement `call(payload, extra)`, where the payload is
|
30
31
|
# the message payload, and the extra argument contains message metadata as
|
@@ -36,7 +37,8 @@ module Pebbles
|
|
36
37
|
:queue,
|
37
38
|
:logger,
|
38
39
|
:on_exception,
|
39
|
-
:managed_acking
|
40
|
+
:managed_acking,
|
41
|
+
:prefetch)
|
40
42
|
|
41
43
|
unless handler.respond_to?(:call)
|
42
44
|
raise ArgumentError.new('Handler must implement #call protocool')
|
@@ -50,7 +52,7 @@ module Pebbles
|
|
50
52
|
end
|
51
53
|
@on_exception = options[:on_exception] || ->(*args) { }
|
52
54
|
@handler = handler
|
53
|
-
@river = River.new
|
55
|
+
@river = River.new(options.slice(:prefetch))
|
54
56
|
@next_event_time = Time.now
|
55
57
|
@rate_limiter = RateLimiter.new(1.0, 10)
|
56
58
|
@logger = options.fetch(:logger, Logger.new($stderr))
|
data/spec/lib/river_spec.rb
CHANGED
@@ -8,7 +8,7 @@ require 'spec_helper'
|
|
8
8
|
describe Pebbles::River::River do
|
9
9
|
|
10
10
|
subject do
|
11
|
-
Pebbles::River::River.new('whatever')
|
11
|
+
Pebbles::River::River.new(environment: 'whatever')
|
12
12
|
end
|
13
13
|
|
14
14
|
CONNECTION_EXCEPTIONS = [
|
@@ -42,7 +42,7 @@ describe Pebbles::River::River do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "in production" do
|
45
|
-
subject { Pebbles::River::River.new('production') }
|
45
|
+
subject { Pebbles::River::River.new(environment: 'production') }
|
46
46
|
|
47
47
|
it "doesn't append the thing" do
|
48
48
|
subject.connect
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pebbles-river
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Staubo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pebblebed
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.4.6
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: Implements an event river mechanism for Pebblebed.
|