evt-consumer 0.2.1.0 → 0.3.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 +9 -31
- data/lib/consumer/controls.rb +1 -1
- data/lib/consumer/controls/consumer.rb +2 -2
- data/lib/consumer/controls/consumer/{logs_events.rb → incrementing.rb} +4 -4
- data/lib/consumer/controls/position_store.rb +1 -3
- data/lib/consumer/position_store.rb +42 -21
- data/lib/consumer/position_store/telemetry.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: e1d54c15b94cdb4d5f1bca14b2bef0d35a1d8e82
|
4
|
+
data.tar.gz: 2e44a08b424289ba4225fdbdd6ff7c73e91e3842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20ea5da08362f78ef225d55b8ccc9e7994db823b7d2914e3675812e8e68d8d6011628c83ff91177320bffae50a0044d2a820dde568b9ef1105f3c2f620e09827
|
7
|
+
data.tar.gz: 8999009e287a384350d799f93f91cebb1e74d8a9279dbf86db34d1577fdbd6c134366a28b4ced2b3bab416d93f1ee3bebe1ffe84a1ba446a7a07d389b7bcd697
|
data/lib/consumer/consumer.rb
CHANGED
@@ -8,13 +8,15 @@ module Consumer
|
|
8
8
|
extend Start
|
9
9
|
|
10
10
|
extend HandleMacro
|
11
|
-
extend PositionStoreMacro
|
12
11
|
|
13
12
|
prepend Configure
|
14
13
|
|
15
14
|
initializer :stream
|
16
15
|
|
17
16
|
attr_writer :position_update_interval
|
17
|
+
def position_update_interval
|
18
|
+
@position_update_interval ||= Defaults.position_update_interval
|
19
|
+
end
|
18
20
|
|
19
21
|
attr_accessor :cycle_maximum_milliseconds
|
20
22
|
attr_accessor :cycle_timeout_milliseconds
|
@@ -67,18 +69,12 @@ module Consumer
|
|
67
69
|
end
|
68
70
|
|
69
71
|
module Configure
|
70
|
-
def configure(batch_size: nil, session: nil)
|
72
|
+
def configure(batch_size: nil, session: nil, position_store: nil)
|
71
73
|
logger.trace { "Configuring (Batch Size: #{batch_size}, Session: #{session.inspect})" }
|
72
74
|
|
73
75
|
super if defined? super
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
-
unless position_store_class.nil?
|
78
|
-
position_store = position_store_class.configure self, stream
|
79
|
-
|
80
|
-
starting_position = position_store.get
|
81
|
-
end
|
77
|
+
starting_position = self.position_store.get
|
82
78
|
|
83
79
|
subscription = Subscription.configure(
|
84
80
|
self,
|
@@ -96,13 +92,14 @@ module Consumer
|
|
96
92
|
end
|
97
93
|
|
98
94
|
module Build
|
99
|
-
def build(stream_name, batch_size: nil, session: nil, cycle_timeout_milliseconds: nil, cycle_maximum_milliseconds: nil)
|
100
|
-
stream = EventSource::Stream.
|
95
|
+
def build(stream_name, batch_size: nil, position_store: nil, position_update_interval: nil, session: nil, cycle_timeout_milliseconds: nil, cycle_maximum_milliseconds: nil)
|
96
|
+
stream = EventSource::Stream.build stream_name
|
101
97
|
|
102
98
|
instance = new stream
|
99
|
+
instance.position_update_interval = position_update_interval
|
103
100
|
instance.cycle_maximum_milliseconds = cycle_maximum_milliseconds
|
104
101
|
instance.cycle_timeout_milliseconds = cycle_timeout_milliseconds
|
105
|
-
instance.configure batch_size: batch_size, session: session
|
102
|
+
instance.configure batch_size: batch_size, position_store: position_store, session: session
|
106
103
|
instance
|
107
104
|
end
|
108
105
|
end
|
@@ -162,23 +159,4 @@ module Consumer
|
|
162
159
|
@handler_registry ||= HandlerRegistry.new
|
163
160
|
end
|
164
161
|
end
|
165
|
-
|
166
|
-
module PositionStoreMacro
|
167
|
-
def self.extended(cls)
|
168
|
-
cls.singleton_class.class_exec do
|
169
|
-
attr_accessor :position_store_class
|
170
|
-
attr_writer :position_update_interval
|
171
|
-
|
172
|
-
def position_update_interval
|
173
|
-
@position_update_interval ||= Defaults.position_update_interval
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def position_store_macro(position_store_class, update_interval: nil)
|
179
|
-
self.position_store_class = position_store_class
|
180
|
-
self.position_update_interval = update_interval
|
181
|
-
end
|
182
|
-
alias_method :position_store, :position_store_macro
|
183
|
-
end
|
184
162
|
end
|
data/lib/consumer/controls.rb
CHANGED
@@ -9,10 +9,10 @@ module Consumer
|
|
9
9
|
include ::Consumer
|
10
10
|
|
11
11
|
handle Handle::Example
|
12
|
-
position_store PositionStore::Example
|
13
12
|
|
14
|
-
def configure(session: nil, batch_size: nil)
|
13
|
+
def configure(session: nil, batch_size: nil, position_store: nil)
|
15
14
|
Get::Example.configure self
|
15
|
+
PositionStore::Example.configure self, position_store: position_store
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module Consumer
|
4
|
-
class
|
4
|
+
class Incrementing
|
5
5
|
include ::Consumer
|
6
6
|
|
7
7
|
def self.logger
|
@@ -16,13 +16,13 @@ module Consumer
|
|
16
16
|
logger.debug { event_data.data.pretty_inspect }
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
def configure(session: nil, batch_size: nil)
|
19
|
+
def configure(session: nil, batch_size: nil, position_store: nil)
|
22
20
|
sleep_duration = ENV['SLEEP_DURATION'] || 100
|
23
21
|
sleep_duration = sleep_duration.to_i
|
24
22
|
|
25
23
|
Get::Incrementing.configure self, sleep_duration
|
24
|
+
|
25
|
+
PositionStore::LocalFile.configure self, position_store: position_store
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -5,33 +5,65 @@ module Consumer
|
|
5
5
|
include Log::Dependency
|
6
6
|
|
7
7
|
extend Build
|
8
|
+
extend ClassConfigure
|
8
9
|
|
10
|
+
prepend Configure
|
9
11
|
prepend Get
|
10
12
|
prepend Put
|
11
13
|
|
12
|
-
configure :position_store
|
13
|
-
|
14
|
-
initializer :stream
|
15
|
-
|
16
14
|
dependency :telemetry, ::Telemetry
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
18
|
Virtual::Method.define self, :configure
|
21
19
|
|
20
|
+
module Build
|
21
|
+
def build
|
22
|
+
instance = new
|
23
|
+
instance.configure
|
24
|
+
instance
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module ClassConfigure
|
29
|
+
def configure(receiver, *arguments, position_store: nil, attr_name: nil, **keyword_arguments)
|
30
|
+
attr_name ||= :position_store
|
31
|
+
|
32
|
+
if position_store.nil?
|
33
|
+
if arguments.any?
|
34
|
+
position_store = build *arguments, **keyword_arguments
|
35
|
+
else
|
36
|
+
position_store = build *arguments
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
receiver.public_send "#{attr_name}=", position_store
|
41
|
+
|
42
|
+
position_store
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Configure
|
47
|
+
def configure
|
48
|
+
::Telemetry.configure self
|
49
|
+
|
50
|
+
super
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
22
54
|
module Get
|
23
55
|
def self.prepended(cls)
|
24
56
|
Virtual::PureMethod.define cls, :get
|
25
57
|
end
|
26
58
|
|
27
59
|
def get
|
28
|
-
logger.trace { "Get position
|
60
|
+
logger.trace { "Get position" }
|
29
61
|
|
30
62
|
position = super
|
31
63
|
|
32
|
-
logger.debug { "Get position done (
|
64
|
+
logger.debug { "Get position done (Position: #{position})" }
|
33
65
|
|
34
|
-
telemetry.record :get, Telemetry::Get.new(position
|
66
|
+
telemetry.record :get, Telemetry::Get.new(position)
|
35
67
|
|
36
68
|
position
|
37
69
|
end
|
@@ -43,27 +75,16 @@ module Consumer
|
|
43
75
|
end
|
44
76
|
|
45
77
|
def put(position)
|
46
|
-
logger.trace { "Put position (
|
78
|
+
logger.trace { "Put position (Position: #{position})" }
|
47
79
|
|
48
80
|
super
|
49
81
|
|
50
|
-
logger.debug { "Put position done (
|
82
|
+
logger.debug { "Put position done (Position: #{position})" }
|
51
83
|
|
52
|
-
telemetry.record :put, Telemetry::Put.new(position
|
84
|
+
telemetry.record :put, Telemetry::Put.new(position)
|
53
85
|
|
54
86
|
nil
|
55
87
|
end
|
56
88
|
end
|
57
|
-
|
58
|
-
module Build
|
59
|
-
def build(stream)
|
60
|
-
stream = EventSource::Stream.canonize stream
|
61
|
-
|
62
|
-
instance = new stream
|
63
|
-
::Telemetry.configure instance
|
64
|
-
instance.configure
|
65
|
-
instance
|
66
|
-
end
|
67
|
-
end
|
68
89
|
end
|
69
90
|
end
|
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.
|
4
|
+
version: 0.3.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: 2017-01-
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ntl-actor
|
@@ -78,7 +78,7 @@ files:
|
|
78
78
|
- lib/consumer/controls.rb
|
79
79
|
- lib/consumer/controls/category.rb
|
80
80
|
- lib/consumer/controls/consumer.rb
|
81
|
-
- lib/consumer/controls/consumer/
|
81
|
+
- lib/consumer/controls/consumer/incrementing.rb
|
82
82
|
- lib/consumer/controls/cycle.rb
|
83
83
|
- lib/consumer/controls/error.rb
|
84
84
|
- lib/consumer/controls/event_data.rb
|