evt-consumer 0.9.0.3 → 0.10.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cc3d6431dff7865c8f5233900d1841c5153e1135d90a5dfca0f5238016d9178
4
- data.tar.gz: 3e345a03e9b7a6abd430faa5462c2bfa348b00f895e955428bc6dd72291973aa
3
+ metadata.gz: 7a93391825108de34561c03f36c7e2319388cc63dad3809c2dd8e96a710dceff
4
+ data.tar.gz: 4f18345dc270025a494488f07b7961cbb854e708c9d649f3f821c5b2ad7a959d
5
5
  SHA512:
6
- metadata.gz: 55e63385a74af095f01d6ed8ab70b03305e66bb2f730c30be4e9aa753df6ff767ab37ea14b1ecd134d74b0a3a24882e6bde48810422a904b7605fa5060e1b832
7
- data.tar.gz: 96df5e691619f8ea5ab260d6d6add64512df7f194d793ef5bcc45be3a257e9057e6cc10dc9e5381acb8589b1e0179a96561b430f2a758840d08c26c7c2f9ddce
6
+ metadata.gz: fdd0b3542210e9984e9f7364b72239f663822b3d7632c3c328a3d591d046616f7566e0ef0486dc5e241055905f19df850310e61db0cf0b17887e28721e114925
7
+ data.tar.gz: 52c7945be88a0d169a9dcdcbc159cf6e5c4ef5a82e3d787830b86f8b004d7070bd60cd31eb2b51a8bb12a3b93ee3728f7caf2cd1cf40444f00b89fdde881a33e
data/lib/consumer.rb CHANGED
@@ -4,6 +4,7 @@ require 'configure'; Configure.activate
4
4
  require 'poll'
5
5
  require 'messaging'
6
6
  require 'log'
7
+ require 'settings'
7
8
 
8
9
  require 'consumer/log'
9
10
  require 'consumer/log_text'
@@ -16,9 +17,6 @@ require 'consumer/position_store'
16
17
  require 'consumer/position_store/substitute'
17
18
  require 'consumer/position_store/telemetry'
18
19
 
19
- require 'consumer/dispatch'
20
- require 'consumer/dispatch/substitute'
21
-
22
20
  require 'consumer/subscription'
23
21
  require 'consumer/subscription/defaults'
24
22
  require 'consumer/subscription/get_batch'
@@ -26,7 +26,7 @@ module Consumer
26
26
  request_batch
27
27
 
28
28
  messages.each do |message_data|
29
- consumer.(message_data)
29
+ consumer.dispatch(message_data)
30
30
  end
31
31
 
32
32
  logger.debug { "Batch received (Events: #{messages.count})" }
@@ -13,14 +13,25 @@ module Consumer
13
13
 
14
14
  initializer :stream_name
15
15
 
16
+ attr_writer :identifier
17
+ def identifier
18
+ @identifier ||= self.class.identifier
19
+ end
20
+
16
21
  attr_writer :position_update_interval
17
22
  def position_update_interval
18
23
  @position_update_interval ||= Defaults.position_update_interval
19
24
  end
20
25
 
26
+ attr_writer :position_update_counter
27
+ def position_update_counter
28
+ @position_update_counter ||= 0
29
+ end
30
+
31
+ attr_accessor :session
32
+
21
33
  attr_accessor :poll_interval_milliseconds
22
34
 
23
- dependency :dispatch, Dispatch
24
35
  dependency :get
25
36
  dependency :position_store, PositionStore
26
37
  dependency :subscription, Subscription
@@ -28,13 +39,17 @@ module Consumer
28
39
  virtual :error_raised do |error, message_data|
29
40
  raise error
30
41
  end
42
+
43
+ alias_method :call, :dispatch
31
44
  end
32
45
  end
33
46
 
34
- def call(message_data)
47
+ def dispatch(message_data)
35
48
  logger.trace { "Dispatching message (#{LogText.message_data(message_data)})" }
36
49
 
37
- dispatch.(message_data)
50
+ self.class.handler_registry.each do |handler|
51
+ handler.(message_data, session: session)
52
+ end
38
53
 
39
54
  update_position(message_data.global_position)
40
55
 
@@ -45,10 +60,6 @@ module Consumer
45
60
  error_raised(error, message_data)
46
61
  end
47
62
 
48
- def identifier
49
- self.class.identifier
50
- end
51
-
52
63
  def start(&probe)
53
64
  _, subscription_thread = ::Actor::Start.(subscription)
54
65
 
@@ -63,28 +74,22 @@ module Consumer
63
74
  AsyncInvocation::Incorrect
64
75
  end
65
76
 
66
- def add_handler(handler)
67
- dispatch.add_handler handler
68
- end
69
-
70
77
  def update_position(position)
71
- logger.trace { "Updating position (Position: #{position}, Interval: #{position_update_interval})" }
78
+ logger.trace { "Updating position (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
72
79
 
73
- position_offset = position % position_update_interval
80
+ self.position_update_counter += 1
74
81
 
75
- if position_offset == 0
82
+ if position_update_counter >= position_update_interval
76
83
  position_store.put(position)
77
84
 
78
- logger.debug { "Updated position (Position: #{position}, Interval: #{position_update_interval})" }
85
+ logger.debug { "Updated position (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
86
+
87
+ self.position_update_counter = 0
79
88
  else
80
- logger.debug { "Interval not reached; position not updated (Position: #{position}, Interval: #{position_update_interval})" }
89
+ logger.debug { "Interval not reached; position not updated (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
81
90
  end
82
91
  end
83
92
 
84
- def position_update_interval
85
- @position_update_interval ||= self.class.position_update_interval
86
- end
87
-
88
93
  module LogText
89
94
  def self.message_data(message_data)
90
95
  "Type: #{message_data.type}, Stream: #{message_data.stream_name}, Position: #{message_data.position}, GlobalPosition: #{message_data.global_position}"
@@ -92,10 +97,10 @@ module Consumer
92
97
  end
93
98
 
94
99
  module Configure
95
- def configure(batch_size: nil, session: nil, position_store: nil, **)
96
- logger.trace { "Configuring (Batch Size: #{batch_size}, Session: #{session.inspect})" }
100
+ def configure(**kwargs)
101
+ logger.trace { "Configuring (Stream Name: #{stream_name})" }
97
102
 
98
- super if defined?(super)
103
+ super(**kwargs)
99
104
 
100
105
  starting_position = self.position_store.get
101
106
 
@@ -107,22 +112,22 @@ module Consumer
107
112
  poll_interval_milliseconds: poll_interval_milliseconds
108
113
  )
109
114
 
110
- handlers = self.class.handler_registry.get(self)
111
-
112
- dispatch = Dispatch.configure(self, handlers)
113
-
114
- logger.debug { "Done configuring (Batch Size: #{batch_size}, Session: #{session.inspect}, Starting Position: #{starting_position})" }
115
+ logger.debug { "Done configuring (Stream Name: #{stream_name}, Starting Position: #{starting_position})" }
115
116
  end
116
117
  end
117
118
 
118
119
  module Build
119
- def build(stream_name, batch_size: nil, position_store: nil, position_update_interval: nil, session: nil, poll_interval_milliseconds: nil, **arguments)
120
- instance = new stream_name
120
+ def build(stream_name, position_update_interval: nil, poll_interval_milliseconds: nil, identifier: nil, **arguments)
121
+ instance = new(stream_name)
122
+
123
+ unless identifier.nil?
124
+ instance.identifier = identifier
125
+ end
121
126
 
122
127
  instance.position_update_interval = position_update_interval
123
128
  instance.poll_interval_milliseconds = poll_interval_milliseconds
124
129
 
125
- instance.configure(batch_size: batch_size, position_store: position_store, session: session, **arguments)
130
+ instance.configure(**arguments)
126
131
 
127
132
  instance
128
133
  end
@@ -7,15 +7,19 @@ 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'
10
- require 'consumer/controls/handle'
11
10
  require 'consumer/controls/id'
12
11
  require 'consumer/controls/identifier'
13
12
  require 'consumer/controls/position'
13
+ require 'consumer/controls/session'
14
14
  require 'consumer/controls/stream_name'
15
15
 
16
16
  require 'consumer/controls/position_store'
17
17
  require 'consumer/controls/position_store/local_file'
18
18
  require 'consumer/controls/subscription'
19
19
 
20
+ require 'consumer/controls/handle'
21
+ require 'consumer/controls/handle/raise_error'
22
+
20
23
  require 'consumer/controls/consumer'
21
24
  require 'consumer/controls/consumer/incrementing'
25
+ require 'consumer/controls/consumer/error_handler'
@@ -1,20 +1,63 @@
1
1
  module Consumer
2
2
  module Controls
3
3
  module Consumer
4
- def self.example
5
- Example.new(StreamName.example)
4
+ def self.example(stream_name=nil, identifier: nil, handlers: nil)
5
+ stream_name ||= StreamName.example
6
+
7
+ cls = example_class(identifier: identifier, handlers: handlers)
8
+
9
+ cls.new(stream_name)
6
10
  end
7
11
 
8
- class Example
9
- include ::Consumer
12
+ def self.example_class(identifier: nil, handlers: nil)
13
+ if identifier == :none
14
+ identifier = nil
15
+ else
16
+ identifier ||= Identifier.random
17
+ end
18
+
19
+ if handlers == :none
20
+ handlers = []
21
+ else
22
+ handlers ||= [
23
+ Handle.example_class,
24
+ Handle.example_class
25
+ ]
26
+ end
27
+
28
+ Class.new do
29
+ include ::Consumer
30
+
31
+ handlers.each do |handler_cls|
32
+ handler handler_cls
33
+ end
10
34
 
11
- handler Handle::Example
35
+ unless identifier.nil?
36
+ identifier identifier
37
+ end
12
38
 
13
- def configure(batch_size: nil, session: nil, position_store: nil, **)
14
- Get::Example.configure(self)
15
- PositionStore::Example.configure(self, position_store: position_store)
39
+ def configure(settings: nil, **)
40
+ Controls::Session::Example.configure(self, settings)
41
+
42
+ Get::Example.configure(self)
43
+ PositionStore::Example.configure(self)
44
+ end
45
+
46
+ def handled_messages
47
+ handled_messages = []
48
+
49
+ self.class.handler_registry.each do |handler|
50
+ next unless handler.ancestors.include?(Handle)
51
+
52
+ handled_messages += handler.handled_messages
53
+ end
54
+
55
+ handled_messages
56
+ end
16
57
  end
17
58
  end
59
+
60
+ Example = self.example_class
18
61
  end
19
62
  end
20
63
  end
@@ -0,0 +1,40 @@
1
+ module Consumer
2
+ module Controls
3
+ module Consumer
4
+ module ErrorHandler
5
+ def self.example(stream_name=nil)
6
+ stream_name ||= StreamName.example
7
+
8
+ Example.new(stream_name)
9
+ end
10
+
11
+ class Example
12
+ include ::Consumer
13
+
14
+ attr_accessor :handled_error
15
+ attr_accessor :failed_message
16
+
17
+ handler Handle::Example
18
+ handler Handle::RaiseError
19
+
20
+ def error_raised(error, message)
21
+ self.handled_error = error
22
+ self.failed_message = message
23
+ end
24
+
25
+ def handled_error?(error=nil)
26
+ if error.nil?
27
+ !handled_error.nil?
28
+ else
29
+ handled_error == error
30
+ end
31
+ end
32
+
33
+ def failed_message?(message)
34
+ failed_message == message
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -5,21 +5,36 @@ module Consumer
5
5
  include ::Consumer
6
6
  include ::Log::Dependency
7
7
 
8
- handler do |message_data|
9
- logger.info { "Handled event (StreamName: #{message_data.stream_name}, GlobalPosition: #{message_data.global_position})" }
10
- end
8
+ module Handlers
9
+ class PrintSummary
10
+ include Messaging::Handle
11
+ include Log::Dependency
12
+
13
+ def handle(message_data)
14
+ logger.info { "Handled event (StreamName: #{message_data.stream_name}, GlobalPosition: #{message_data.global_position})" }
15
+ end
16
+ end
11
17
 
12
- handler do |message_data|
13
- logger.debug { message_data.data.pretty_inspect }
18
+ class PrintData
19
+ include Messaging::Handle
20
+ include Log::Dependency
21
+
22
+ def handle(message_data)
23
+ logger.debug { message_data.data.pretty_inspect }
24
+ end
25
+ end
14
26
  end
15
27
 
16
- def configure(session: nil, batch_size: nil, position_store: nil)
28
+ handler Handlers::PrintSummary
29
+ handler Handlers::PrintData
30
+
31
+ def configure
17
32
  sleep_duration = ENV['SLEEP_DURATION'] || 100
18
33
  sleep_duration = sleep_duration.to_i
19
34
 
20
35
  Get::Incrementing.configure(self, sleep_duration)
21
36
 
22
- PositionStore::LocalFile.configure(self, position_store: position_store)
37
+ PositionStore::LocalFile.configure(self, identifier: identifier)
23
38
  end
24
39
  end
25
40
  end
@@ -6,6 +6,8 @@ module Consumer
6
6
  end
7
7
 
8
8
  class Example
9
+ extend ::Configure::Macro
10
+
9
11
  configure :get
10
12
 
11
13
  def self.build
@@ -2,18 +2,26 @@ module Consumer
2
2
  module Controls
3
3
  module Get
4
4
  class Incrementing
5
+ extend ::Configure::Macro
6
+
5
7
  configure :get
6
8
 
7
- initializer :sleep_duration
9
+ initializer :frequency_milliseconds
10
+
11
+ def frequency_seconds
12
+ frequency_milliseconds.to_f / 1000
13
+ end
14
+
15
+ def self.build(frequency_milliseconds=nil)
16
+ frequency_milliseconds ||= Defaults.frequency_milliseconds
8
17
 
9
- def self.build(sleep_duration)
10
- new(sleep_duration)
18
+ new(frequency_milliseconds)
11
19
  end
12
20
 
13
21
  def call(stream_name, position: nil)
14
22
  position ||= 0
15
23
 
16
- sleep Rational(sleep_duration, 1000)
24
+ sleep(frequency_seconds)
17
25
 
18
26
  3.times.map do |offset|
19
27
  MessageData.get(
@@ -23,21 +31,27 @@ module Consumer
23
31
  )
24
32
  end
25
33
  end
26
- end
27
34
 
28
- class MessageData
29
- def self.get(stream_name, global_position, position)
30
- data = {
31
- :position => position,
32
- :global_position => global_position
33
- }
34
-
35
- Controls::MessageData.example(
36
- stream_name: stream_name,
37
- data: data,
38
- global_position: global_position,
39
- position: position
40
- )
35
+ module Defaults
36
+ def self.frequency_milliseconds
37
+ 100
38
+ end
39
+ end
40
+
41
+ class MessageData
42
+ def self.get(stream_name, global_position, position)
43
+ data = {
44
+ :position => position,
45
+ :global_position => global_position
46
+ }
47
+
48
+ Controls::MessageData.example(
49
+ stream_name: stream_name,
50
+ data: data,
51
+ global_position: global_position,
52
+ position: position
53
+ )
54
+ end
41
55
  end
42
56
  end
43
57
  end
@@ -2,24 +2,51 @@ module Consumer
2
2
  module Controls
3
3
  module Handle
4
4
  def self.example
5
- Example.new
5
+ example_class.new
6
6
  end
7
7
 
8
- class Example
9
- include Messaging::Handle
8
+ def self.example_class
9
+ Class.new do
10
+ include Messaging::Handle
11
+ include Handle
10
12
 
11
- def handle(message_data)
12
- handled_messages << message_data
13
- end
13
+ attr_accessor :session
14
14
 
15
- def handled_messages
16
- @handled_messages ||= []
17
- end
15
+ def configure(session: nil)
16
+ self.session = session
17
+ end
18
+
19
+ def self.handled_messages
20
+ @@handled_messages ||= []
21
+ end
22
+
23
+ def handle(message_data)
24
+ handled_messages << message_data
25
+ end
18
26
 
19
- def handled?(message_data)
20
- handled_messages.include?(message_data)
27
+ def handled_messages
28
+ self.class.handled_messages
29
+ end
30
+
31
+ def handled?(message_data=nil)
32
+ if message_data.nil?
33
+ handled_messages.any?
34
+ else
35
+ handled_messages.include?(message_data)
36
+ end
37
+ end
38
+
39
+ def session?(session=nil)
40
+ if session.nil?
41
+ !self.session.nil?
42
+ else
43
+ session == self.session
44
+ end
45
+ end
21
46
  end
22
47
  end
48
+
49
+ Example = self.example_class
23
50
  end
24
51
  end
25
52
  end
@@ -0,0 +1,17 @@
1
+ module Consumer
2
+ module Controls
3
+ module Handle
4
+ module RaiseError
5
+ class Example
6
+ include Messaging::Handle
7
+
8
+ def handle(message_data)
9
+ error_text = "Example error (Message: #{message_data.type}, Stream: #{message_data.stream_name}, Position: #{message_data.position}, Global Position: #{message_data.global_position})"
10
+
11
+ raise Error::Example, error_text
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,8 +1,18 @@
1
1
  module Consumer
2
2
  module Controls
3
3
  module Identifier
4
- def self.example
5
- 'some-consumer'
4
+ def self.example(random: nil)
5
+ random ||= false
6
+
7
+ unless random
8
+ 'some-consumer'
9
+ else
10
+ "some-consumer-#{SecureRandom.hex(8)}"
11
+ end
12
+ end
13
+
14
+ def self.random
15
+ example(random: true)
6
16
  end
7
17
  end
8
18
  end
@@ -5,9 +5,12 @@ module Consumer
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
+
9
11
  message_data.position = position unless position.nil?
10
12
  message_data.global_position = global_position unless global_position.nil?
13
+
11
14
  message_data
12
15
  end
13
16
  end
@@ -3,15 +3,19 @@ module Consumer
3
3
  module PositionStore
4
4
  class LocalFile
5
5
  include Consumer::PositionStore
6
+ extend Initializer::Macro
6
7
 
7
- def self.build
8
- instance = new
8
+ initializer(:identifier)
9
+
10
+ def self.build(identifier: nil)
11
+ instance = new(identifier)
9
12
  instance.configure
10
13
  instance
11
14
  end
12
15
 
13
16
  def get
14
17
  return 0 unless File.exist?(path)
18
+
15
19
  text = File.read(path)
16
20
  text.to_i
17
21
  end
@@ -21,7 +25,13 @@ module Consumer
21
25
  end
22
26
 
23
27
  def path
24
- 'tmp/control_position_store'
28
+ path = File.join('tmp', 'local_file_position_store')
29
+
30
+ unless identifier.nil?
31
+ path << "-#{identifier}"
32
+ end
33
+
34
+ path
25
35
  end
26
36
  end
27
37
  end
@@ -0,0 +1,59 @@
1
+ module Consumer
2
+ module Controls
3
+ module Session
4
+ def self.example(settings=nil)
5
+ Example.build(settings)
6
+ end
7
+
8
+ class Example
9
+ extend ::Configure::Macro
10
+ extend ::Settings::Setting::Macro
11
+
12
+ configure :session
13
+
14
+ setting :some_setting
15
+ setting :other_setting
16
+
17
+ def self.build(settings=nil)
18
+ settings ||= Settings.example
19
+
20
+ instance = new
21
+ settings.set(instance)
22
+ instance
23
+ end
24
+
25
+ def settings?(other_settings)
26
+ self.some_setting == other_settings.get(:some_setting) &&
27
+ self.other_setting == other_settings.get(:other_setting)
28
+ end
29
+
30
+ def ==(other_session)
31
+ other_session.is_a?(self.class) &&
32
+ self.some_setting == other_session.some_setting &&
33
+ self.other_setting == other_session.other_setting
34
+ end
35
+ end
36
+
37
+ module Settings
38
+ def self.example
39
+ Example.build
40
+ end
41
+
42
+ class Example < ::Settings
43
+ def self.data_source
44
+ Raw.example
45
+ end
46
+ end
47
+
48
+ module Raw
49
+ def self.example
50
+ {
51
+ :some_setting => SecureRandom.hex(7),
52
+ :other_setting => SecureRandom.hex(7)
53
+ }
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -4,34 +4,34 @@ module Consumer
4
4
 
5
5
  configure :handler_registry
6
6
 
7
+ def entries
8
+ @entries ||= Set.new
9
+ end
10
+
11
+ def count
12
+ entries.count
13
+ end
14
+
15
+ def each(&block)
16
+ entries.each(&block)
17
+ end
18
+
7
19
  def register(handler)
8
- logger.trace { "Registering handler (Handler: #{LogText.handler(handler)})" }
20
+ logger.trace { "Registering handler (Handler: #{handler.name})" }
9
21
 
10
22
  if registered? handler
11
- error_message = "Handler is already registered (Handler: #{LogText.handler(handler)})"
23
+ error_message = "Handler is already registered (Handler: #{handler.name})"
12
24
  logger.error { error_message }
13
25
  raise Error, error_message
14
26
  end
15
27
 
16
28
  entries << handler
17
29
 
18
- logger.debug { "Handler registered (Handler: #{LogText.handler(handler)})" }
30
+ logger.debug { "Handler registered (Handler: #{handler.name})" }
19
31
 
20
32
  handler
21
33
  end
22
34
 
23
- def get(consumer)
24
- entries.map do |handler|
25
- if handler.is_a? Proc
26
- proc { |message_data|
27
- consumer.instance_exec(message_data, &handler)
28
- }
29
- else
30
- handler.build
31
- end
32
- end
33
- end
34
-
35
35
  def registered?(handler)
36
36
  entries.any? do |entry|
37
37
  return true if handler == entry
@@ -42,24 +42,6 @@ module Consumer
42
42
  end
43
43
  end
44
44
 
45
- def entries
46
- @entries ||= Set.new
47
- end
48
-
49
- def count
50
- entries.count
51
- end
52
-
53
- module LogText
54
- def self.handler(handler)
55
- case handler
56
- when Module then handler.name
57
- when Proc then '(proc)'
58
- else handler.inspect
59
- end
60
- end
61
- end
62
-
63
45
  Error = Class.new(RuntimeError)
64
46
  end
65
47
  end
@@ -19,20 +19,22 @@ module Consumer
19
19
 
20
20
  module Build
21
21
  def self.extended(cls)
22
- Virtual::PureMethod.define(cls.singleton_class, :build)
22
+ cls.singleton_class.class_exec do
23
+ extend Virtual::Macro
24
+
25
+ abstract :build
26
+ end
23
27
  end
24
28
  end
25
29
 
26
30
  module ClassConfigure
27
- def configure(receiver, *arguments, position_store: nil, attr_name: nil, **keyword_arguments)
31
+ def configure(receiver, *arguments, attr_name: nil, **keyword_arguments)
28
32
  attr_name ||= :position_store
29
33
 
30
- if position_store.nil?
31
- if arguments.any?
32
- position_store = build(*arguments, **keyword_arguments)
33
- else
34
- position_store = build(*arguments)
35
- end
34
+ if keyword_arguments.any?
35
+ position_store = build(*arguments, **keyword_arguments)
36
+ else
37
+ position_store = build(*arguments)
36
38
  end
37
39
 
38
40
  receiver.public_send("#{attr_name}=", position_store)
@@ -5,7 +5,7 @@ module Consumer
5
5
  end
6
6
 
7
7
  class Consumer
8
- def call(message_data)
8
+ def dispatch(message_data)
9
9
  dispatched_messages << message_data
10
10
  end
11
11
 
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.9.0.3
4
+ version: 0.10.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: 2018-09-03 00:00:00.000000000 Z
11
+ date: 2018-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ntl-actor
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: evt-settings
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: test_bench
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -92,11 +106,13 @@ files:
92
106
  - lib/consumer/controls.rb
93
107
  - lib/consumer/controls/category.rb
94
108
  - lib/consumer/controls/consumer.rb
109
+ - lib/consumer/controls/consumer/error_handler.rb
95
110
  - lib/consumer/controls/consumer/incrementing.rb
96
111
  - lib/consumer/controls/error.rb
97
112
  - lib/consumer/controls/get.rb
98
113
  - lib/consumer/controls/get/incrementing.rb
99
114
  - lib/consumer/controls/handle.rb
115
+ - lib/consumer/controls/handle/raise_error.rb
100
116
  - lib/consumer/controls/id.rb
101
117
  - lib/consumer/controls/identifier.rb
102
118
  - lib/consumer/controls/message_data.rb
@@ -105,11 +121,10 @@ files:
105
121
  - lib/consumer/controls/position.rb
106
122
  - lib/consumer/controls/position_store.rb
107
123
  - lib/consumer/controls/position_store/local_file.rb
124
+ - lib/consumer/controls/session.rb
108
125
  - lib/consumer/controls/stream_name.rb
109
126
  - lib/consumer/controls/subscription.rb
110
127
  - lib/consumer/defaults.rb
111
- - lib/consumer/dispatch.rb
112
- - lib/consumer/dispatch/substitute.rb
113
128
  - lib/consumer/handler_registry.rb
114
129
  - lib/consumer/log.rb
115
130
  - lib/consumer/log_text.rb
@@ -140,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
155
  version: '0'
141
156
  requirements: []
142
157
  rubyforge_project:
143
- rubygems_version: 2.7.3
158
+ rubygems_version: 2.7.6
144
159
  signing_key:
145
160
  specification_version: 4
146
161
  summary: Continuous subscription to a stream and message dispatching to handlers
@@ -1,43 +0,0 @@
1
- module Consumer
2
- class Dispatch
3
- include Log::Dependency
4
-
5
- def handlers
6
- @handlers ||= []
7
- end
8
-
9
- configure :dispatch
10
-
11
- def self.build(handlers=nil)
12
- handlers = Array(handlers)
13
-
14
- instance = new
15
-
16
- handlers.each do |handler|
17
- instance.add_handler(handler)
18
- end
19
-
20
- instance
21
- end
22
-
23
- def call(message_data)
24
- logger.trace { "Dispatching event (#{LogText.message_data(message_data)})" }
25
-
26
- handlers.each do |handle|
27
- handle.(message_data)
28
- end
29
-
30
- logger.debug { "Event dispatched (#{LogText.message_data(message_data)}, Handlers Count: #{handlers.count})" }
31
-
32
- nil
33
- end
34
-
35
- def add_handler(handler)
36
- handlers << handler
37
- end
38
-
39
- def to_proc
40
- method(:call)
41
- end
42
- end
43
- end
@@ -1,41 +0,0 @@
1
- module Consumer
2
- class Dispatch
3
- module Substitute
4
- def self.build
5
- Dispatch.new
6
- end
7
-
8
- class Dispatch
9
- def call(message_data)
10
- dispatched_messages << message_data
11
- end
12
-
13
- def add_handler(handle)
14
- handlers << handle
15
- end
16
-
17
- def dispatched_messages
18
- @dispatched_messages ||= []
19
- end
20
-
21
- def dispatched?(message_data=nil, &block)
22
- if message_data.nil?
23
- block ||= proc { true }
24
- else
25
- block ||= proc { |msg| message_data == msg }
26
- end
27
-
28
- dispatched_messages.any? &block
29
- end
30
-
31
- def handlers
32
- @handlers ||= []
33
- end
34
-
35
- def handler?(handler)
36
- handlers.include?(handler)
37
- end
38
- end
39
- end
40
- end
41
- end