evt-consumer 1.1.0.0 → 2.2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/consumer/consumer.rb +18 -13
- data/lib/consumer/controls/consumer.rb +3 -3
- data/lib/consumer/controls/consumer/error_handler.rb +3 -3
- data/lib/consumer/controls/consumer/incrementing.rb +1 -1
- data/lib/consumer/controls/get/incrementing.rb +9 -8
- data/lib/consumer/controls/message_data.rb +1 -3
- data/lib/consumer/controls/stream_name.rb +1 -0
- data/lib/consumer/controls/subscription.rb +2 -2
- data/lib/consumer/subscription.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d005131cba1d68a95028facee2e86fb2936e29ae0fe296a746f4e0e25abfc910
|
4
|
+
data.tar.gz: caf16c231eb6195749b4b2190843ab87aed7735f4fd3b3da72555bab45f8ea76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 332338327a4a4fc99a3010e1e62b0dd840d64914efba85d3f90a22a001df3215c43f49933b213ac6ae7bef78dfe2018b3cb6dcf051c40b42eb278e5d547dd0a8
|
7
|
+
data.tar.gz: 76e5105a629fbd97447d2423139b08ecf1d33a1cdb513bc662cacf3e4ec969888ee2b3da677fdc009583490f313d9067effac3e1c9087ee074ff9760d2bca24a
|
data/lib/consumer/consumer.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Consumer
|
2
|
+
Error = Class.new(RuntimeError)
|
3
|
+
|
2
4
|
def self.included(cls)
|
3
5
|
cls.class_exec do
|
4
6
|
include Dependency
|
@@ -14,7 +16,7 @@ module Consumer
|
|
14
16
|
|
15
17
|
prepend Configure
|
16
18
|
|
17
|
-
initializer :
|
19
|
+
initializer :category
|
18
20
|
|
19
21
|
attr_writer :identifier
|
20
22
|
def identifier
|
@@ -35,7 +37,7 @@ module Consumer
|
|
35
37
|
|
36
38
|
attr_accessor :poll_interval_milliseconds
|
37
39
|
|
38
|
-
dependency :get
|
40
|
+
dependency :get, MessageStore::Get
|
39
41
|
dependency :position_store, PositionStore
|
40
42
|
dependency :subscription, Subscription
|
41
43
|
|
@@ -57,19 +59,22 @@ module Consumer
|
|
57
59
|
update_position(message_data.global_position)
|
58
60
|
|
59
61
|
logger.info { "Message dispatched (#{LogText.message_data(message_data)})" }
|
60
|
-
|
61
62
|
rescue => error
|
62
63
|
logger.error { "Error raised (Error Class: #{error.class}, Error Message: #{error.message}, #{LogText.message_data(message_data)})" }
|
63
64
|
error_raised(error, message_data)
|
64
65
|
end
|
65
66
|
|
66
67
|
def start(&probe)
|
67
|
-
logger.info(tag: :*) { "Starting consumer: #{self.class.name} (
|
68
|
+
logger.info(tag: :*) { "Starting consumer: #{self.class.name} (Category: #{category}, Identifier: #{identifier || '(none)'}, Position: #{subscription.position})" }
|
69
|
+
|
70
|
+
if not MessageStore::StreamName.category?(category)
|
71
|
+
raise Error, "Consumer's stream name must be a category (Stream Name: #{category})"
|
72
|
+
end
|
68
73
|
|
69
74
|
starting() if respond_to?(:starting)
|
70
75
|
|
71
76
|
self.class.handler_registry.each do |handler|
|
72
|
-
logger.info(tag: :*) { "Handler: #{handler.name} (
|
77
|
+
logger.info(tag: :*) { "Handler: #{handler.name} (Category: #{category}, Consumer: #{self.class.name})" }
|
73
78
|
end
|
74
79
|
|
75
80
|
_, subscription_thread = ::Actor::Start.(subscription)
|
@@ -82,7 +87,7 @@ module Consumer
|
|
82
87
|
probe.(self, [actor_thread, subscription_thread], [actor_address, subscription_address])
|
83
88
|
end
|
84
89
|
|
85
|
-
logger.info(tag: :*) { "Started consumer: #{self.class.name} (
|
90
|
+
logger.info(tag: :*) { "Started consumer: #{self.class.name} (Category: #{category}, Identifier: #{identifier || '(none)'}, Position: #{subscription.position})" }
|
86
91
|
|
87
92
|
AsyncInvocation::Incorrect
|
88
93
|
end
|
@@ -105,13 +110,13 @@ module Consumer
|
|
105
110
|
|
106
111
|
module LogText
|
107
112
|
def self.message_data(message_data)
|
108
|
-
"Type: #{message_data.type}, Stream: #{message_data.stream_name}, Position: #{message_data.position}, GlobalPosition: #{message_data.global_position}"
|
113
|
+
"Type: #{message_data.type}, Stream Name: #{message_data.stream_name}, Position: #{message_data.position}, GlobalPosition: #{message_data.global_position}"
|
109
114
|
end
|
110
115
|
end
|
111
116
|
|
112
117
|
module Configure
|
113
118
|
def configure(**kwargs)
|
114
|
-
logger.trace { "Configuring (
|
119
|
+
logger.trace { "Configuring (Category: #{category})" }
|
115
120
|
|
116
121
|
super(**kwargs)
|
117
122
|
|
@@ -124,13 +129,13 @@ module Consumer
|
|
124
129
|
poll_interval_milliseconds: poll_interval_milliseconds
|
125
130
|
)
|
126
131
|
|
127
|
-
logger.debug { "Done configuring (
|
132
|
+
logger.debug { "Done configuring (Category: #{category}, Starting Position: #{starting_position})" }
|
128
133
|
end
|
129
134
|
end
|
130
135
|
|
131
136
|
module Build
|
132
|
-
def build(
|
133
|
-
instance = new(
|
137
|
+
def build(category, position_update_interval: nil, poll_interval_milliseconds: nil, identifier: nil, **arguments)
|
138
|
+
instance = new(category)
|
134
139
|
|
135
140
|
unless identifier.nil?
|
136
141
|
instance.identifier = identifier
|
@@ -146,8 +151,8 @@ module Consumer
|
|
146
151
|
end
|
147
152
|
|
148
153
|
module Start
|
149
|
-
def start(
|
150
|
-
instance = build
|
154
|
+
def start(category, **arguments, &probe)
|
155
|
+
instance = build category, **arguments
|
151
156
|
instance.start(&probe)
|
152
157
|
end
|
153
158
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module Consumer
|
4
|
-
def self.example(
|
5
|
-
|
4
|
+
def self.example(category=nil, identifier: nil, handlers: nil)
|
5
|
+
category ||= Category.example
|
6
6
|
|
7
7
|
cls = example_class(identifier: identifier, handlers: handlers)
|
8
8
|
|
9
|
-
cls.new(
|
9
|
+
cls.new(category)
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.example_class(identifier: nil, handlers: nil)
|
@@ -2,10 +2,10 @@ module Consumer
|
|
2
2
|
module Controls
|
3
3
|
module Consumer
|
4
4
|
module ErrorHandler
|
5
|
-
def self.example(
|
6
|
-
|
5
|
+
def self.example(category=nil)
|
6
|
+
category ||= Category.example
|
7
7
|
|
8
|
-
Example.new(
|
8
|
+
Example.new(category)
|
9
9
|
end
|
10
10
|
|
11
11
|
class Example
|
@@ -32,7 +32,7 @@ module Consumer
|
|
32
32
|
sleep_duration = ENV['SLEEP_DURATION'] || 100
|
33
33
|
sleep_duration = sleep_duration.to_i
|
34
34
|
|
35
|
-
Get::Incrementing.configure(self,
|
35
|
+
Get::Incrementing.configure(self, sleep_duration)
|
36
36
|
|
37
37
|
PositionStore::File.configure(self, identifier: identifier)
|
38
38
|
end
|
@@ -7,16 +7,19 @@ module Consumer
|
|
7
7
|
|
8
8
|
configure :get
|
9
9
|
|
10
|
-
|
10
|
+
def frequency_milliseconds
|
11
|
+
@frequency_milliseconds ||= Defaults.frequency_milliseconds
|
12
|
+
end
|
13
|
+
attr_writer :frequency_milliseconds
|
11
14
|
|
12
15
|
def frequency_seconds
|
13
16
|
frequency_milliseconds.to_f / 1000
|
14
17
|
end
|
15
18
|
|
16
|
-
def self.build(
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
def self.build(frequency_milliseconds=nil)
|
20
|
+
instance = new
|
21
|
+
instance.frequency_milliseconds = frequency_milliseconds
|
22
|
+
instance
|
20
23
|
end
|
21
24
|
|
22
25
|
def batch_size
|
@@ -30,7 +33,6 @@ module Consumer
|
|
30
33
|
|
31
34
|
batch_size.times.map do |offset|
|
32
35
|
MessageData.example(
|
33
|
-
stream_name,
|
34
36
|
position + offset,
|
35
37
|
offset
|
36
38
|
)
|
@@ -48,14 +50,13 @@ module Consumer
|
|
48
50
|
end
|
49
51
|
|
50
52
|
class MessageData
|
51
|
-
def self.example(
|
53
|
+
def self.example(global_position, position)
|
52
54
|
data = {
|
53
55
|
:position => position,
|
54
56
|
:global_position => global_position
|
55
57
|
}
|
56
58
|
|
57
59
|
Controls::MessageData.example(
|
58
|
-
stream_name: stream_name,
|
59
60
|
data: data,
|
60
61
|
global_position: global_position,
|
61
62
|
position: position
|
@@ -1,13 +1,11 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module MessageData
|
4
|
-
def self.example(
|
4
|
+
def self.example(data: nil, position: nil, global_position: nil)
|
5
5
|
global_position ||= position
|
6
6
|
|
7
7
|
message_data = MessageStore::Controls::MessageData::Read.example(data: data)
|
8
8
|
|
9
|
-
message_data.stream_name = stream_name unless stream_name.nil?
|
10
|
-
|
11
9
|
message_data.position = position unless position.nil?
|
12
10
|
message_data.global_position = global_position unless global_position.nil?
|
13
11
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module Subscription
|
4
|
-
def self.example(
|
5
|
-
get = Get.example(stream_name:
|
4
|
+
def self.example(category: nil, next_batch: nil, position: nil, batch_size: nil, count: nil)
|
5
|
+
get = Get.example(stream_name: category, batch_size: batch_size, count: count)
|
6
6
|
|
7
7
|
subscription = ::Consumer::Subscription.new(get)
|
8
8
|
|
@@ -46,20 +46,20 @@ module Consumer
|
|
46
46
|
end
|
47
47
|
|
48
48
|
handle :resupply do
|
49
|
-
logger.trace { "Resupplying (
|
49
|
+
logger.trace { "Resupplying (Category: #{get.category}, Position: #{position})" }
|
50
50
|
|
51
51
|
batch = poll.() do
|
52
52
|
get.(position)
|
53
53
|
end
|
54
54
|
|
55
55
|
if batch.nil? || batch.empty?
|
56
|
-
logger.debug { "Did not resupply; no events available (
|
56
|
+
logger.debug { "Did not resupply; no events available (Category: #{get.category}, Position: #{position})" }
|
57
57
|
|
58
58
|
:resupply
|
59
59
|
else
|
60
60
|
self.next_batch = batch
|
61
61
|
|
62
|
-
logger.debug { "Resupplied (
|
62
|
+
logger.debug { "Resupplied (Category: #{get.category}, Position: #{position}, Batch Size: #{batch.count})" }
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
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:
|
4
|
+
version: 2.2.0.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: 2019-10
|
11
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ntl-actor
|
@@ -158,5 +158,5 @@ requirements: []
|
|
158
158
|
rubygems_version: 3.0.1
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
|
-
summary: Continuous subscription to a
|
161
|
+
summary: Continuous subscription to a category and message dispatching to handlers
|
162
162
|
test_files: []
|