evt-consumer 0.3.0.0 → 0.4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/consumer/consumer.rb +3 -1
- data/lib/consumer/controls/handle.rb +4 -0
- data/lib/consumer/dispatch.rb +4 -10
- data/lib/consumer/handler_registry.rb +12 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 134d9b7fe4b0476ee089ba6646012669a6d43a03
|
4
|
+
data.tar.gz: 6db97a91b342d36eb65b6a7927048ea37e194228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14b0bbed2bc44dc641cb303dc34dea202601e7f84020b13bba2d8b7a005a3efe6c7e8b4116ecc4166065f86a793724319664c66dd5a0d86f5efca6cd239d028b
|
7
|
+
data.tar.gz: 37f83db9333ca9eed131af329ade0da14cda1509370f61f48420f0f051560210fbd90baded6bf0462ad4822aa703b7881835d65a97abea99922ad4b22348c609
|
data/lib/consumer/consumer.rb
CHANGED
@@ -85,7 +85,9 @@ module Consumer
|
|
85
85
|
cycle_timeout_milliseconds: cycle_timeout_milliseconds
|
86
86
|
)
|
87
87
|
|
88
|
-
|
88
|
+
handlers = self.class.handler_registry.get self
|
89
|
+
|
90
|
+
dispatch = Dispatch.configure self, handlers
|
89
91
|
|
90
92
|
logger.debug { "Configuring (Batch Size: #{batch_size}, Session: #{session.inspect})" }
|
91
93
|
end
|
data/lib/consumer/dispatch.rb
CHANGED
@@ -4,23 +4,17 @@ module Consumer
|
|
4
4
|
|
5
5
|
configure :dispatch
|
6
6
|
|
7
|
-
|
7
|
+
initializer :handlers
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
end
|
9
|
+
def self.build(handlers=nil)
|
10
|
+
handlers = Array(handlers)
|
12
11
|
|
13
|
-
|
14
|
-
instance = new
|
15
|
-
instance.handler_registry = handler_registry unless handler_registry.nil?
|
16
|
-
instance
|
12
|
+
new handlers
|
17
13
|
end
|
18
14
|
|
19
15
|
def call(event_data)
|
20
16
|
logger.trace { "Dispatching event (#{LogText.event_data event_data})" }
|
21
17
|
|
22
|
-
handlers = handler_registry.get
|
23
|
-
|
24
18
|
handlers.each do |handle|
|
25
19
|
handle.(event_data)
|
26
20
|
end
|
@@ -13,21 +13,23 @@ module Consumer
|
|
13
13
|
raise Error, error_message
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
instance = handler.build
|
18
|
-
else
|
19
|
-
instance = handler
|
20
|
-
end
|
21
|
-
|
22
|
-
entries << instance
|
16
|
+
entries << handler
|
23
17
|
|
24
18
|
logger.debug { "Handler registered (Handler: #{LogText.handler handler})" }
|
25
19
|
|
26
|
-
|
20
|
+
handler
|
27
21
|
end
|
28
22
|
|
29
|
-
def get
|
30
|
-
entries.
|
23
|
+
def get(consumer)
|
24
|
+
entries.map do |handler|
|
25
|
+
if handler.is_a? Proc
|
26
|
+
proc { |event_data|
|
27
|
+
consumer.instance_exec event_data, &handler
|
28
|
+
}
|
29
|
+
else
|
30
|
+
handler.build
|
31
|
+
end
|
32
|
+
end
|
31
33
|
end
|
32
34
|
|
33
35
|
def registered?(handler)
|