evt-consumer 0.5.0.0 → 0.5.0.1
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 +2 -2
- data/lib/consumer/consumer.rb +10 -10
- data/lib/consumer/controls.rb +2 -2
- data/lib/consumer/controls/category.rb +1 -1
- data/lib/consumer/controls/consumer/incrementing.rb +4 -4
- data/lib/consumer/controls/get/incrementing.rb +3 -3
- data/lib/consumer/controls/handle.rb +4 -4
- data/lib/consumer/controls/message_data.rb +15 -0
- data/lib/consumer/controls/{event_data → message_data}/batch.rb +2 -2
- data/lib/consumer/controls/position.rb +2 -2
- data/lib/consumer/dispatch.rb +4 -4
- data/lib/consumer/dispatch/substitute.rb +5 -5
- data/lib/consumer/handler_registry.rb +2 -2
- data/lib/consumer/log_text.rb +2 -2
- data/lib/consumer/position_store.rb +2 -2
- data/lib/consumer/substitute.rb +5 -5
- metadata +5 -5
- data/lib/consumer/controls/event_data.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b7ba7639868951557d06b7a6c7fa66bf4141e3c
|
4
|
+
data.tar.gz: b7d2764110d1f64263e83871eab9e515b36c7002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf143797978d8cfa068b6aea5232031c95c30339e189b0743675b50d74662217d3216916a87d54b1e1a5785067a642e08fe9321bab95cfd1ef1ca999956ed9a6
|
7
|
+
data.tar.gz: 6be8716feac2cf472d9c5226a7a312f5418b5a8431b9831d51ce536dc4c66f116884a3a2455dd75d2514aa008f90d2a63d4efa10b76a8585733e3b23ec18220a
|
data/lib/consumer/actor.rb
CHANGED
data/lib/consumer/consumer.rb
CHANGED
@@ -28,18 +28,18 @@ module Consumer
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def call(
|
32
|
-
logger.trace { "Dispatching event (#{LogText.
|
31
|
+
def call(message_data)
|
32
|
+
logger.trace { "Dispatching event (#{LogText.message_data message_data})" }
|
33
33
|
|
34
|
-
dispatch.(
|
34
|
+
dispatch.(message_data)
|
35
35
|
|
36
|
-
update_position
|
36
|
+
update_position message_data.global_position
|
37
37
|
|
38
|
-
logger.info { "Event dispatched (#{LogText.
|
38
|
+
logger.info { "Event dispatched (#{LogText.message_data message_data})" }
|
39
39
|
|
40
40
|
rescue => error
|
41
|
-
logger.error { "Error raised (Error Class: #{error.class}, Error Message: #{error.message}, #{LogText.
|
42
|
-
error_raised error,
|
41
|
+
logger.error { "Error raised (Error Class: #{error.class}, Error Message: #{error.message}, #{LogText.message_data message_data})" }
|
42
|
+
error_raised error, message_data
|
43
43
|
end
|
44
44
|
|
45
45
|
def run(&probe)
|
@@ -103,8 +103,8 @@ module Consumer
|
|
103
103
|
end
|
104
104
|
|
105
105
|
module LogText
|
106
|
-
def self.
|
107
|
-
"Stream: #{
|
106
|
+
def self.message_data(message_data)
|
107
|
+
"Stream: #{message_data.stream_name}, Position: #{message_data.position}, GlobalPosition: #{message_data.global_position}, Type: #{message_data.type}"
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
@@ -129,7 +129,7 @@ module Consumer
|
|
129
129
|
|
130
130
|
dispatch = Dispatch.configure self, handlers
|
131
131
|
|
132
|
-
logger.debug { "
|
132
|
+
logger.debug { "Done configuring (Batch Size: #{batch_size}, Session: #{session.inspect}, Starting Position: #{starting_position})" }
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
data/lib/consumer/controls.rb
CHANGED
@@ -2,8 +2,8 @@ require 'messaging/controls'
|
|
2
2
|
|
3
3
|
require 'consumer/controls/category'
|
4
4
|
require 'consumer/controls/cycle'
|
5
|
-
require 'consumer/controls/
|
6
|
-
require 'consumer/controls/
|
5
|
+
require 'consumer/controls/message_data'
|
6
|
+
require 'consumer/controls/message_data/batch'
|
7
7
|
require 'consumer/controls/error'
|
8
8
|
require 'consumer/controls/get'
|
9
9
|
require 'consumer/controls/get/incrementing'
|
@@ -8,12 +8,12 @@ module Consumer
|
|
8
8
|
@logger ||= ::Log.get self
|
9
9
|
end
|
10
10
|
|
11
|
-
handler do |
|
12
|
-
logger.info { "Handled event (StreamName: #{
|
11
|
+
handler do |message_data|
|
12
|
+
logger.info { "Handled event (StreamName: #{message_data.stream_name}, GlobalPosition: #{message_data.global_position})" }
|
13
13
|
end
|
14
14
|
|
15
|
-
handler do |
|
16
|
-
logger.debug {
|
15
|
+
handler do |message_data|
|
16
|
+
logger.debug { message_data.data.pretty_inspect }
|
17
17
|
end
|
18
18
|
|
19
19
|
def configure(session: nil, batch_size: nil, position_store: nil)
|
@@ -16,7 +16,7 @@ module Consumer
|
|
16
16
|
sleep Rational(sleep_duration, 1000)
|
17
17
|
|
18
18
|
3.times.map do |offset|
|
19
|
-
|
19
|
+
MessageData.get(
|
20
20
|
stream_name,
|
21
21
|
position + offset,
|
22
22
|
offset
|
@@ -25,11 +25,11 @@ module Consumer
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
class
|
28
|
+
class MessageData
|
29
29
|
def self.get(stream_name, global_position, position)
|
30
30
|
data = { :position => position, :global_position => global_position }
|
31
31
|
|
32
|
-
Controls::
|
32
|
+
Controls::MessageData.example(
|
33
33
|
stream_name: stream_name,
|
34
34
|
data: data,
|
35
35
|
global_position: global_position,
|
@@ -8,16 +8,16 @@ module Consumer
|
|
8
8
|
class Example
|
9
9
|
include Messaging::Handle
|
10
10
|
|
11
|
-
def handle(
|
12
|
-
handled_events <<
|
11
|
+
def handle(message_data)
|
12
|
+
handled_events << message_data
|
13
13
|
end
|
14
14
|
|
15
15
|
def handled_events
|
16
16
|
@handled_events ||= []
|
17
17
|
end
|
18
18
|
|
19
|
-
def handled?(
|
20
|
-
handled_events.include?
|
19
|
+
def handled?(message_data)
|
20
|
+
handled_events.include? message_data
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Consumer
|
2
|
+
module Controls
|
3
|
+
module MessageData
|
4
|
+
def self.example(stream_name: nil, data: nil, position: nil, global_position: nil)
|
5
|
+
global_position ||= position
|
6
|
+
|
7
|
+
message_data = MessageStore::Controls::MessageData::Read.example(data: data)
|
8
|
+
message_data.stream_name = stream_name unless stream_name.nil?
|
9
|
+
message_data.position = position unless position.nil?
|
10
|
+
message_data.global_position = global_position unless global_position.nil?
|
11
|
+
message_data
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
|
-
module
|
3
|
+
module MessageData
|
4
4
|
module Batch
|
5
5
|
def self.example(instances: nil, position: nil)
|
6
6
|
instances ||= size
|
@@ -9,7 +9,7 @@ module Consumer
|
|
9
9
|
instances.times.map do |offset|
|
10
10
|
position = start_position + offset
|
11
11
|
|
12
|
-
|
12
|
+
MessageData.example(global_position: position)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -3,7 +3,7 @@ module Consumer
|
|
3
3
|
module Position
|
4
4
|
module Stream
|
5
5
|
def self.example
|
6
|
-
|
6
|
+
MessageStore::Controls::MessageData.position
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -11,7 +11,7 @@ module Consumer
|
|
11
11
|
def self.example(offset: nil)
|
12
12
|
offset ||= 0
|
13
13
|
|
14
|
-
position =
|
14
|
+
position = MessageStore::Controls::MessageData::Read.global_position
|
15
15
|
|
16
16
|
position + offset
|
17
17
|
end
|
data/lib/consumer/dispatch.rb
CHANGED
@@ -16,14 +16,14 @@ module Consumer
|
|
16
16
|
instance
|
17
17
|
end
|
18
18
|
|
19
|
-
def call(
|
20
|
-
logger.trace { "Dispatching event (#{LogText.
|
19
|
+
def call(message_data)
|
20
|
+
logger.trace { "Dispatching event (#{LogText.message_data message_data})" }
|
21
21
|
|
22
22
|
handlers.each do |handle|
|
23
|
-
handle.(
|
23
|
+
handle.(message_data)
|
24
24
|
end
|
25
25
|
|
26
|
-
logger.debug { "Event dispatched (#{LogText.
|
26
|
+
logger.debug { "Event dispatched (#{LogText.message_data message_data}, Handlers Count: #{handlers.count})" }
|
27
27
|
|
28
28
|
nil
|
29
29
|
end
|
@@ -6,8 +6,8 @@ module Consumer
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Dispatch
|
9
|
-
def call(
|
10
|
-
dispatched_events <<
|
9
|
+
def call(message_data)
|
10
|
+
dispatched_events << message_data
|
11
11
|
end
|
12
12
|
|
13
13
|
def add_handler(handle)
|
@@ -18,11 +18,11 @@ module Consumer
|
|
18
18
|
@dispatched_events ||= []
|
19
19
|
end
|
20
20
|
|
21
|
-
def dispatched?(
|
22
|
-
if
|
21
|
+
def dispatched?(message_data=nil, &block)
|
22
|
+
if message_data.nil?
|
23
23
|
block ||= proc { true }
|
24
24
|
else
|
25
|
-
block ||= proc { |e|
|
25
|
+
block ||= proc { |e| message_data == e }
|
26
26
|
end
|
27
27
|
|
28
28
|
dispatched_events.any? &block
|
@@ -23,8 +23,8 @@ module Consumer
|
|
23
23
|
def get(consumer)
|
24
24
|
entries.map do |handler|
|
25
25
|
if handler.is_a? Proc
|
26
|
-
proc { |
|
27
|
-
consumer.instance_exec
|
26
|
+
proc { |message_data|
|
27
|
+
consumer.instance_exec message_data, &handler
|
28
28
|
}
|
29
29
|
else
|
30
30
|
handler.build
|
data/lib/consumer/log_text.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Consumer
|
2
2
|
module LogText
|
3
|
-
def self.
|
4
|
-
"Stream: #{
|
3
|
+
def self.message_data(message_data)
|
4
|
+
"Stream: #{message_data.stream_name}, Position: #{message_data.position}, GlobalPosition: #{message_data.global_position}, Type: #{message_data.type}"
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -61,7 +61,7 @@ module Consumer
|
|
61
61
|
|
62
62
|
position = super
|
63
63
|
|
64
|
-
logger.
|
64
|
+
logger.info { "Get position done (Position: #{position || '(none)'})" }
|
65
65
|
|
66
66
|
telemetry.record :get, Telemetry::Get.new(position)
|
67
67
|
|
@@ -79,7 +79,7 @@ module Consumer
|
|
79
79
|
|
80
80
|
super
|
81
81
|
|
82
|
-
logger.
|
82
|
+
logger.info { "Put position done (Position: #{position})" }
|
83
83
|
|
84
84
|
telemetry.record :put, Telemetry::Put.new(position)
|
85
85
|
|
data/lib/consumer/substitute.rb
CHANGED
@@ -5,19 +5,19 @@ module Consumer
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class Consumer
|
8
|
-
def call(
|
9
|
-
consumed_events <<
|
8
|
+
def call(message_data)
|
9
|
+
consumed_events << message_data
|
10
10
|
end
|
11
11
|
|
12
12
|
def consumed_events
|
13
13
|
@consumed_events ||= []
|
14
14
|
end
|
15
15
|
|
16
|
-
def consumed?(
|
17
|
-
if
|
16
|
+
def consumed?(message_data=nil, &block)
|
17
|
+
if message_data.nil?
|
18
18
|
block ||= proc { true }
|
19
19
|
else
|
20
|
-
block ||= proc { |e|
|
20
|
+
block ||= proc { |e| message_data == e }
|
21
21
|
end
|
22
22
|
|
23
23
|
consumed_events.any? &block
|
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.5.0.
|
4
|
+
version: 0.5.0.1
|
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-
|
11
|
+
date: 2017-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ntl-actor
|
@@ -95,12 +95,12 @@ files:
|
|
95
95
|
- lib/consumer/controls/consumer/incrementing.rb
|
96
96
|
- lib/consumer/controls/cycle.rb
|
97
97
|
- lib/consumer/controls/error.rb
|
98
|
-
- lib/consumer/controls/event_data.rb
|
99
|
-
- lib/consumer/controls/event_data/batch.rb
|
100
98
|
- lib/consumer/controls/get.rb
|
101
99
|
- lib/consumer/controls/get/incrementing.rb
|
102
100
|
- lib/consumer/controls/handle.rb
|
103
101
|
- lib/consumer/controls/id.rb
|
102
|
+
- lib/consumer/controls/message_data.rb
|
103
|
+
- lib/consumer/controls/message_data/batch.rb
|
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
|
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
requirements:
|
132
132
|
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version: 2.
|
134
|
+
version: 2.4.0
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Consumer
|
2
|
-
module Controls
|
3
|
-
module EventData
|
4
|
-
def self.example(stream_name: nil, data: nil, position: nil, global_position: nil)
|
5
|
-
global_position ||= position
|
6
|
-
|
7
|
-
event_data = EventSource::Controls::EventData::Read.example data: data
|
8
|
-
event_data.stream_name = stream_name unless stream_name.nil?
|
9
|
-
event_data.position = position unless position.nil?
|
10
|
-
event_data.global_position = global_position unless global_position.nil?
|
11
|
-
event_data
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|