evt-consumer 0.11.0.3 → 0.11.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/consumer/actor.rb +49 -10
- data/lib/consumer/controls.rb +2 -0
- data/lib/consumer/controls/actor.rb +24 -0
- data/lib/consumer/controls/get.rb +15 -5
- data/lib/consumer/controls/session.rb +2 -2
- data/lib/consumer/controls/subscription.rb +2 -2
- data/lib/consumer/subscription.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d59370128eb98868d476174baba504dbfcd3bd07f2fe0aa1cf262cf88d63f99e
|
4
|
+
data.tar.gz: a89e817d675aca9cf8d635c5cf73c184dc67bffa6fe0431606d9bfa67acea9e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 572476d4ba197f55312e1b42f64785aa12e54aa6a0b009569a6892ca45ecfdaaf4506691ebb39f49a24212633478a0a0ca42f06cf9ac3654a6e738b7800fe086
|
7
|
+
data.tar.gz: 46fd4742ec78e986bf6c99f8411a78506963c8c173eaec5c7057f49631904bb7d176549293bec7fc231962a33447e8328ee9af70d212f76ab6bfa4e581d4ca2d
|
data/lib/consumer/actor.rb
CHANGED
@@ -5,12 +5,21 @@ module Consumer
|
|
5
5
|
include Initializer
|
6
6
|
include Log::Dependency
|
7
7
|
|
8
|
-
initializer :subscription_address
|
8
|
+
initializer :subscription_address, a(:delay_threshold)
|
9
9
|
|
10
10
|
dependency :consumer, Consumer
|
11
11
|
|
12
|
+
attr_writer :prefetch_queue
|
13
|
+
def prefetch_queue
|
14
|
+
@prefetch_queue ||= []
|
15
|
+
end
|
16
|
+
|
12
17
|
def self.build(consumer, subscription)
|
13
|
-
|
18
|
+
subscription_address = subscription.address
|
19
|
+
|
20
|
+
delay_threshold = subscription.batch_size
|
21
|
+
|
22
|
+
instance = new(subscription_address, delay_threshold)
|
14
23
|
instance.consumer = consumer
|
15
24
|
instance.configure
|
16
25
|
instance
|
@@ -21,27 +30,57 @@ module Consumer
|
|
21
30
|
end
|
22
31
|
|
23
32
|
handle Subscription::GetBatch::Reply do |get_batch_reply|
|
24
|
-
|
33
|
+
received_batch = get_batch_reply.batch
|
25
34
|
|
26
|
-
logger.trace { "Received batch (
|
35
|
+
logger.trace(tag: :actor) { "Received batch (Received Batch Size: #{received_batch.size}, Prefetch Queue Depth: #{prefetch_queue.size}, Delay Threshold: #{delay_threshold})" }
|
27
36
|
|
28
|
-
|
37
|
+
prefetch_queue_empty = prefetch_queue.empty?
|
38
|
+
|
39
|
+
self.prefetch_queue += received_batch
|
40
|
+
|
41
|
+
unless prefetch_queue.size > delay_threshold
|
42
|
+
request_batch
|
43
|
+
end
|
44
|
+
|
45
|
+
if prefetch_queue_empty
|
46
|
+
next_message = :dispatch
|
47
|
+
end
|
29
48
|
|
30
|
-
|
31
|
-
|
49
|
+
logger.debug(tag: :actor) { "Batch received (Received Batch Size: #{received_batch.size}, Prefetch Queue Depth: #{prefetch_queue.size}, Delay Threshold: #{delay_threshold}, Next Actor Message: #{next_message || '(none)'})" }
|
50
|
+
|
51
|
+
next_message
|
52
|
+
end
|
53
|
+
|
54
|
+
handle :dispatch do
|
55
|
+
logger.trace(tag: :actor) { "Dispatching Message (Prefetch Queue Depth: #{prefetch_queue.size}, Delay Threshold: #{delay_threshold})" }
|
56
|
+
|
57
|
+
dispatch_message = prefetch_queue.shift
|
58
|
+
|
59
|
+
if prefetch_queue.size == delay_threshold
|
60
|
+
request_batch
|
32
61
|
end
|
33
62
|
|
34
|
-
|
63
|
+
consumer.dispatch(dispatch_message)
|
64
|
+
|
65
|
+
unless prefetch_queue.empty?
|
66
|
+
next_message = :dispatch
|
67
|
+
end
|
68
|
+
|
69
|
+
logger.debug(tag: :actor) { "Dispatched Message (Prefetch Queue Depth: #{prefetch_queue.size}, Delay Threshold: #{delay_threshold}, Global Position: #{dispatch_message.global_position}, Next Actor Message: #{next_message || '(none)'})" }
|
70
|
+
|
71
|
+
next_message
|
35
72
|
end
|
36
73
|
|
37
74
|
def request_batch
|
38
|
-
logger.trace { "Requesting batch" }
|
75
|
+
logger.trace(tag: :actor) { "Requesting batch (Prefetch Queue Depth: #{prefetch_queue.size}, Delay Threshold: #{delay_threshold})" }
|
39
76
|
|
40
77
|
get_batch = Subscription::GetBatch.new(address)
|
41
78
|
|
42
79
|
send.(get_batch, subscription_address)
|
43
80
|
|
44
|
-
logger.debug { "
|
81
|
+
logger.debug(tag: :actor) { "Sent batch request (Prefetch Queue Depth: #{prefetch_queue.size}, Delay Threshold: #{delay_threshold})" }
|
82
|
+
|
83
|
+
nil
|
45
84
|
end
|
46
85
|
end
|
47
86
|
end
|
data/lib/consumer/controls.rb
CHANGED
@@ -20,6 +20,8 @@ require 'consumer/controls/subscription'
|
|
20
20
|
require 'consumer/controls/handle'
|
21
21
|
require 'consumer/controls/handle/raise_error'
|
22
22
|
|
23
|
+
require 'consumer/controls/actor'
|
24
|
+
|
23
25
|
require 'consumer/controls/consumer'
|
24
26
|
require 'consumer/controls/consumer/incrementing'
|
25
27
|
require 'consumer/controls/consumer/error_handler'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Consumer
|
2
|
+
module Controls
|
3
|
+
module Actor
|
4
|
+
def self.example(subscription_address: nil, delay_threshold: nil)
|
5
|
+
delay_threshold ||= DelayThreshold.example
|
6
|
+
subscription_address ||= Address.example
|
7
|
+
|
8
|
+
::Consumer::Actor.new(subscription_address, delay_threshold)
|
9
|
+
end
|
10
|
+
|
11
|
+
module DelayThreshold
|
12
|
+
def self.example
|
13
|
+
Get.default_batch_size
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module Address
|
18
|
+
def self.example
|
19
|
+
::Actor::Messaging::Address.build
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,17 +1,27 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module Get
|
4
|
-
def self.example
|
5
|
-
Example.
|
4
|
+
def self.example(batch_size: nil)
|
5
|
+
Example.build(batch_size: batch_size)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.default_batch_size
|
9
|
+
MessageData::Batch.size
|
6
10
|
end
|
7
11
|
|
8
12
|
class Example
|
9
|
-
|
13
|
+
include ::Configure
|
14
|
+
|
15
|
+
include MessageStore::Get
|
16
|
+
|
17
|
+
initializer :batch_size
|
10
18
|
|
11
19
|
configure :get
|
12
20
|
|
13
|
-
def self.build
|
14
|
-
|
21
|
+
def self.build(batch_size: nil)
|
22
|
+
batch_size ||= Get.default_batch_size
|
23
|
+
|
24
|
+
new(batch_size)
|
15
25
|
end
|
16
26
|
|
17
27
|
def call(stream_name, position: nil)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module Subscription
|
4
|
-
def self.example(next_batch: nil, batch: nil, position: nil)
|
4
|
+
def self.example(next_batch: nil, batch: nil, position: nil, batch_size: nil)
|
5
5
|
stream_name = StreamName.example
|
6
6
|
|
7
|
-
get = Get.example
|
7
|
+
get = Get.example(batch_size: batch_size)
|
8
8
|
|
9
9
|
unless batch.nil?
|
10
10
|
get.set_batch(stream_name, batch, position)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-consumer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.0
|
4
|
+
version: 0.11.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ntl-actor
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/consumer/actor.rb
|
105
105
|
- lib/consumer/consumer.rb
|
106
106
|
- lib/consumer/controls.rb
|
107
|
+
- lib/consumer/controls/actor.rb
|
107
108
|
- lib/consumer/controls/category.rb
|
108
109
|
- lib/consumer/controls/consumer.rb
|
109
110
|
- lib/consumer/controls/consumer/error_handler.rb
|