evt-consumer 0.4.0.2 → 0.4.1.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 +47 -38
- data/lib/consumer/controls.rb +0 -1
- data/lib/consumer/controls/consumer.rb +1 -1
- data/lib/consumer/controls/handle.rb +4 -0
- data/lib/consumer/controls/subscription.rb +3 -3
- data/lib/consumer/dispatch.rb +4 -0
- data/lib/consumer/dispatch/substitute.rb +12 -0
- data/lib/consumer/subscription.rb +3 -7
- metadata +2 -3
- data/lib/consumer/controls/stream.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2fdb752c2c2e6a472a1d8f5e366fc547b43c2d8
|
4
|
+
data.tar.gz: 30085cfb53accfc5ddbe2bbfc07b6f291f0bc7fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d93e4722ed90c52ae5b7abc8fd97396e76255033aeb938a12145a0757da77aa6e01cab4681bed5d8bacad5acbd9ac0d4c2e11530a21ba4eba30770db32781547
|
7
|
+
data.tar.gz: f11d4e31aeeeb527621e55463dfcd0693789d41aef69c3af8bf1d5b73680e6dbeefa0084c9228e1dc7c92e837606aee7a76a0775a4a2ce0f8f569390bf1915c9
|
data/lib/consumer/consumer.rb
CHANGED
@@ -11,7 +11,7 @@ module Consumer
|
|
11
11
|
|
12
12
|
prepend Configure
|
13
13
|
|
14
|
-
initializer :
|
14
|
+
initializer :stream_name
|
15
15
|
|
16
16
|
attr_writer :position_update_interval
|
17
17
|
def position_update_interval
|
@@ -42,6 +42,46 @@ module Consumer
|
|
42
42
|
error_raised error, event_data
|
43
43
|
end
|
44
44
|
|
45
|
+
def run(&probe)
|
46
|
+
threads, addresses = nil
|
47
|
+
|
48
|
+
start do |_, _threads, _addresses|
|
49
|
+
threads = _threads
|
50
|
+
addresses = _addresses
|
51
|
+
end
|
52
|
+
|
53
|
+
loop do
|
54
|
+
probe.(self, threads, addresses) if probe
|
55
|
+
consumer.subscription.cycle { nil }
|
56
|
+
end
|
57
|
+
|
58
|
+
addresses.each do |address|
|
59
|
+
Actor::Messaging::Send.(:stop, address)
|
60
|
+
end
|
61
|
+
|
62
|
+
threads.each &:join
|
63
|
+
|
64
|
+
AsyncInvocation::Incorrect
|
65
|
+
end
|
66
|
+
|
67
|
+
def start(&probe)
|
68
|
+
_, subscription_thread = ::Actor::Start.(subscription)
|
69
|
+
|
70
|
+
actor_address, actor_thread = Actor.start self, subscription, include: :thread
|
71
|
+
|
72
|
+
if probe
|
73
|
+
subscription_address = subscription.address
|
74
|
+
|
75
|
+
probe.(self, [actor_thread, subscription_thread], [actor_address, subscription_address])
|
76
|
+
end
|
77
|
+
|
78
|
+
AsyncInvocation::Incorrect
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_handler(handler)
|
82
|
+
dispatch.add_handler handler
|
83
|
+
end
|
84
|
+
|
45
85
|
def error_raised(error, _)
|
46
86
|
raise error
|
47
87
|
end
|
@@ -78,7 +118,7 @@ module Consumer
|
|
78
118
|
|
79
119
|
subscription = Subscription.configure(
|
80
120
|
self,
|
81
|
-
|
121
|
+
stream_name,
|
82
122
|
get,
|
83
123
|
position: starting_position,
|
84
124
|
cycle_maximum_milliseconds: cycle_maximum_milliseconds,
|
@@ -95,9 +135,7 @@ module Consumer
|
|
95
135
|
|
96
136
|
module Build
|
97
137
|
def build(stream_name, batch_size: nil, position_store: nil, position_update_interval: nil, session: nil, cycle_timeout_milliseconds: nil, cycle_maximum_milliseconds: nil)
|
98
|
-
|
99
|
-
|
100
|
-
instance = new stream
|
138
|
+
instance = new stream_name
|
101
139
|
instance.position_update_interval = position_update_interval
|
102
140
|
instance.cycle_maximum_milliseconds = cycle_maximum_milliseconds
|
103
141
|
instance.cycle_timeout_milliseconds = cycle_timeout_milliseconds
|
@@ -107,45 +145,16 @@ module Consumer
|
|
107
145
|
end
|
108
146
|
|
109
147
|
module Run
|
110
|
-
def run(stream_name, **arguments, &
|
111
|
-
|
112
|
-
|
113
|
-
return_value = start stream_name, **arguments do |_consumer, _threads, _addresses|
|
114
|
-
consumer = _consumer
|
115
|
-
threads = _threads
|
116
|
-
addresses = _addresses
|
117
|
-
end
|
118
|
-
|
119
|
-
loop do
|
120
|
-
action.(consumer, threads, addresses) if action
|
121
|
-
consumer.subscription.cycle { nil }
|
122
|
-
end
|
123
|
-
|
124
|
-
addresses.each do |address|
|
125
|
-
Actor::Messaging::Send.(:stop, address)
|
126
|
-
end
|
127
|
-
|
128
|
-
threads.each &:join
|
129
|
-
|
130
|
-
return_value
|
148
|
+
def run(stream_name, **arguments, &probe)
|
149
|
+
instance = build stream_name, **arguments
|
150
|
+
instance.run &probe
|
131
151
|
end
|
132
152
|
end
|
133
153
|
|
134
154
|
module Start
|
135
155
|
def start(stream_name, **arguments, &probe)
|
136
156
|
instance = build stream_name, **arguments
|
137
|
-
|
138
|
-
_, subscription_thread = ::Actor::Start.(instance.subscription)
|
139
|
-
|
140
|
-
actor_address, actor_thread = Actor.start instance, instance.subscription, include: :thread
|
141
|
-
|
142
|
-
if probe
|
143
|
-
subscription_address = instance.subscription.address
|
144
|
-
|
145
|
-
probe.(instance, [actor_thread, subscription_thread], [actor_address, subscription_address])
|
146
|
-
end
|
147
|
-
|
148
|
-
AsyncInvocation::Incorrect
|
157
|
+
instance.start &probe
|
149
158
|
end
|
150
159
|
end
|
151
160
|
|
data/lib/consumer/controls.rb
CHANGED
@@ -10,7 +10,6 @@ require 'consumer/controls/get/incrementing'
|
|
10
10
|
require 'consumer/controls/handle'
|
11
11
|
require 'consumer/controls/id'
|
12
12
|
require 'consumer/controls/position'
|
13
|
-
require 'consumer/controls/stream'
|
14
13
|
require 'consumer/controls/stream_name'
|
15
14
|
|
16
15
|
require 'consumer/controls/position_store'
|
@@ -2,15 +2,15 @@ module Consumer
|
|
2
2
|
module Controls
|
3
3
|
module Subscription
|
4
4
|
def self.example(next_batch: nil, batch: nil, position: nil)
|
5
|
-
|
5
|
+
stream_name = StreamName.example
|
6
6
|
|
7
7
|
get = Get.example
|
8
8
|
|
9
9
|
unless batch.nil?
|
10
|
-
get.set_batch
|
10
|
+
get.set_batch stream_name, batch, position
|
11
11
|
end
|
12
12
|
|
13
|
-
subscription = ::Consumer::Subscription.new
|
13
|
+
subscription = ::Consumer::Subscription.new stream_name, get
|
14
14
|
|
15
15
|
subscription.position = position if position
|
16
16
|
|
data/lib/consumer/dispatch.rb
CHANGED
@@ -10,6 +10,10 @@ module Consumer
|
|
10
10
|
dispatched_events << event_data
|
11
11
|
end
|
12
12
|
|
13
|
+
def add_handler(handle)
|
14
|
+
handlers << handle
|
15
|
+
end
|
16
|
+
|
13
17
|
def dispatched_events
|
14
18
|
@dispatched_events ||= []
|
15
19
|
end
|
@@ -23,6 +27,14 @@ module Consumer
|
|
23
27
|
|
24
28
|
dispatched_events.any? &block
|
25
29
|
end
|
30
|
+
|
31
|
+
def handlers
|
32
|
+
@handlers ||= []
|
33
|
+
end
|
34
|
+
|
35
|
+
def handler?(handler)
|
36
|
+
handlers.include? handler
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
@@ -5,7 +5,7 @@ module Consumer
|
|
5
5
|
|
6
6
|
configure :subscription
|
7
7
|
|
8
|
-
initializer :
|
8
|
+
initializer :stream_name, :get
|
9
9
|
|
10
10
|
attr_accessor :next_batch
|
11
11
|
|
@@ -16,11 +16,11 @@ module Consumer
|
|
16
16
|
|
17
17
|
dependency :cycle, Cycle
|
18
18
|
|
19
|
-
def self.build(
|
19
|
+
def self.build(stream_name, get, position: nil, cycle_maximum_milliseconds: nil, cycle_timeout_milliseconds: nil)
|
20
20
|
cycle_maximum_milliseconds ||= Defaults.cycle_maximum_milliseconds
|
21
21
|
cycle_timeout_milliseconds ||= Defaults.cycle_timeout_milliseconds
|
22
22
|
|
23
|
-
instance = new
|
23
|
+
instance = new stream_name, get
|
24
24
|
|
25
25
|
instance.position = position
|
26
26
|
|
@@ -85,9 +85,5 @@ module Consumer
|
|
85
85
|
|
86
86
|
batch
|
87
87
|
end
|
88
|
-
|
89
|
-
def stream_name
|
90
|
-
stream.name
|
91
|
-
end
|
92
88
|
end
|
93
89
|
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.0
|
4
|
+
version: 0.4.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: 2017-01
|
11
|
+
date: 2017-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ntl-actor
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- lib/consumer/controls/position.rb
|
105
105
|
- lib/consumer/controls/position_store.rb
|
106
106
|
- lib/consumer/controls/position_store/local_file.rb
|
107
|
-
- lib/consumer/controls/stream.rb
|
108
107
|
- lib/consumer/controls/stream_name.rb
|
109
108
|
- lib/consumer/controls/subscription.rb
|
110
109
|
- lib/consumer/defaults.rb
|