active_publisher 0.4.0 → 1.0.0.pre0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c47b026ffd14970af0fdd93efb07c7cc5fa6b649
|
4
|
+
data.tar.gz: 643480a2b1495381a8c6ccfedbdf0d249288def0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 959a8d3a200142c30396ee065fdbb75d8d340eb8f474479c7e98c82795af5dd063eebe90a34156e7bc3e5795512ee20487d8e748ee915f19ae7eaa2a98fdf150
|
7
|
+
data.tar.gz: 6509995dad25e4f492b257f626cab11a3ea8b9b5b759526c24d32c10cafcf72b79c322bcd91910e6853b9955af1477345eac8a69f0669d7dfe532b5ebae47f6b
|
@@ -18,11 +18,11 @@ module ActivePublisher
|
|
18
18
|
|
19
19
|
attr_reader :async_queue
|
20
20
|
|
21
|
-
def initialize(
|
21
|
+
def initialize(back_pressure_strategy = :raise, max_queue_size = 100_000, supervisor_interval = 0.2)
|
22
22
|
logger.info "Starting in-memory publisher adapter"
|
23
23
|
|
24
24
|
@async_queue = ::ActivePublisher::Async::InMemoryAdapter::AsyncQueue.new(
|
25
|
-
|
25
|
+
back_pressure_strategy,
|
26
26
|
max_queue_size,
|
27
27
|
supervisor_interval
|
28
28
|
)
|
@@ -2,30 +2,44 @@ module ActivePublisher
|
|
2
2
|
module Async
|
3
3
|
module InMemoryAdapter
|
4
4
|
class AsyncQueue
|
5
|
+
# These strategies are used to determine what to do with messages when the queue is full.
|
6
|
+
# :raise - Raise an error and drop the message.
|
7
|
+
# :drop - Silently drop the message.
|
8
|
+
# :wait - Wait for space in the queue to become available.
|
9
|
+
BACK_PRESSURE_STRATEGIES = [:raise, :drop, :wait].freeze
|
10
|
+
|
5
11
|
include ::ActivePublisher::Logging
|
6
12
|
|
7
|
-
attr_accessor :
|
13
|
+
attr_accessor :back_pressure_strategy,
|
8
14
|
:max_queue_size,
|
9
15
|
:supervisor_interval
|
10
16
|
|
11
17
|
attr_reader :consumer, :queue, :supervisor
|
12
18
|
|
13
|
-
def initialize(
|
14
|
-
|
19
|
+
def initialize(back_pressure_strategy, max_queue_size, supervisor_interval)
|
20
|
+
self.back_pressure_strategy = back_pressure_strategy
|
15
21
|
@max_queue_size = max_queue_size
|
16
22
|
@supervisor_interval = supervisor_interval
|
17
23
|
@queue = ::MultiOpQueue::Queue.new
|
18
24
|
create_and_supervise_consumer!
|
19
25
|
end
|
20
26
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
return if drop_messages_when_queue_full
|
27
|
+
def back_pressure_strategy=(strategy)
|
28
|
+
fail ::ArgumentError, "Invalid back pressure strategy: #{strategy}" unless BACK_PRESSURE_STRATEGIES.include?(strategy)
|
29
|
+
@back_pressure_strategy = strategy
|
30
|
+
end
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
def push(message)
|
33
|
+
if queue.size >= max_queue_size
|
34
|
+
case back_pressure_strategy
|
35
|
+
when :drop
|
36
|
+
return
|
37
|
+
when :raise
|
38
|
+
fail ::ActivePublisher::Async::InMemoryAdapter::UnableToPersistMessageError, "Queue is full, messages will be dropped."
|
39
|
+
when :wait
|
40
|
+
# This is a really crappy way to wait
|
41
|
+
sleep 0.01 until queue.size < max_queue_size
|
42
|
+
end
|
29
43
|
end
|
30
44
|
|
31
45
|
queue.push(message)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.pre0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: exe
|
14
14
|
cert_chain: []
|
15
|
-
date: 2017-
|
15
|
+
date: 2017-08-28 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bunny
|
@@ -145,12 +145,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|
148
|
-
- - "
|
148
|
+
- - ">"
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
150
|
+
version: 1.3.1
|
151
151
|
requirements: []
|
152
152
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.5.2
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: Aims to make publishing work across MRI and jRuby painless and add some nice
|