evt-consumer 1.0.2.0 → 1.1.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 +0 -1
- data/lib/consumer/controls.rb +1 -1
- data/lib/consumer/controls/actor.rb +1 -1
- data/lib/consumer/controls/consumer.rb +2 -1
- data/lib/consumer/controls/consumer/incrementing.rb +2 -2
- data/lib/consumer/controls/get.rb +1 -49
- data/lib/consumer/controls/get/incrementing.rb +6 -6
- data/lib/consumer/controls/message_data.rb +2 -0
- data/lib/consumer/controls/position.rb +4 -2
- data/lib/consumer/controls/position_store/{local_file.rb → file.rb} +5 -5
- data/lib/consumer/controls/subscription.rb +3 -9
- data/lib/consumer/subscription.rb +7 -7
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2077ef49032cd7e88e66307072188bd14f3f5eb60c3889d3eaa2d8e32d398a91
|
4
|
+
data.tar.gz: db192f1c6a7d6c7629200fdb71152d325ec05fcd27f1acf17d2f6f7a77088a77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e80126fd3557847a29603838d917b11fbdc93b617cca9ac17ea2c68471d6c1cef76c9e15656a306bf4959ff6ea80f9615db120fb8c72d37ca8096b3c2ed5c187
|
7
|
+
data.tar.gz: 4c64c89911619b136db60fc135619c17573410083ce86cf0fc4438254133b8bd1724f0123536393f58b783830a60c46248ba2cf62f58b96b8d4dd0852d52dcfd
|
data/lib/consumer/consumer.rb
CHANGED
data/lib/consumer/controls.rb
CHANGED
@@ -14,7 +14,7 @@ require 'consumer/controls/session'
|
|
14
14
|
require 'consumer/controls/stream_name'
|
15
15
|
|
16
16
|
require 'consumer/controls/position_store'
|
17
|
-
require 'consumer/controls/position_store/
|
17
|
+
require 'consumer/controls/position_store/file'
|
18
18
|
require 'consumer/controls/subscription'
|
19
19
|
|
20
20
|
require 'consumer/controls/handle'
|
@@ -32,9 +32,9 @@ module Consumer
|
|
32
32
|
sleep_duration = ENV['SLEEP_DURATION'] || 100
|
33
33
|
sleep_duration = sleep_duration.to_i
|
34
34
|
|
35
|
-
Get::Incrementing.configure(self, sleep_duration)
|
35
|
+
Get::Incrementing.configure(self, stream_name, sleep_duration)
|
36
36
|
|
37
|
-
PositionStore::
|
37
|
+
PositionStore::File.configure(self, identifier: identifier)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,53 +1,5 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
|
-
|
4
|
-
def self.example(batch_size: nil)
|
5
|
-
Example.build(batch_size: batch_size)
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.default_batch_size
|
9
|
-
MessageData::Batch.size
|
10
|
-
end
|
11
|
-
|
12
|
-
class Example
|
13
|
-
include ::Configure
|
14
|
-
|
15
|
-
include MessageStore::Get
|
16
|
-
|
17
|
-
initializer :batch_size
|
18
|
-
|
19
|
-
configure :get
|
20
|
-
|
21
|
-
def self.build(batch_size: nil)
|
22
|
-
batch_size ||= Get.default_batch_size
|
23
|
-
|
24
|
-
new(batch_size)
|
25
|
-
end
|
26
|
-
|
27
|
-
def call(stream_name, position: nil)
|
28
|
-
position ||= 0
|
29
|
-
|
30
|
-
stream = streams.fetch(stream_name) do
|
31
|
-
return nil
|
32
|
-
end
|
33
|
-
|
34
|
-
stream[position]
|
35
|
-
end
|
36
|
-
|
37
|
-
def set_batch(stream_name, batch, position=nil)
|
38
|
-
position ||= 0
|
39
|
-
|
40
|
-
stream = streams[stream_name]
|
41
|
-
|
42
|
-
stream[position] = batch
|
43
|
-
end
|
44
|
-
|
45
|
-
def streams
|
46
|
-
@streams ||= Hash.new do |hash, key|
|
47
|
-
hash[key] = {}
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
3
|
+
Get = MessageStore::Controls::Get
|
52
4
|
end
|
53
5
|
end
|
@@ -7,29 +7,29 @@ module Consumer
|
|
7
7
|
|
8
8
|
configure :get
|
9
9
|
|
10
|
-
initializer :frequency_milliseconds
|
10
|
+
initializer :stream_name, :frequency_milliseconds
|
11
11
|
|
12
12
|
def frequency_seconds
|
13
13
|
frequency_milliseconds.to_f / 1000
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.build(frequency_milliseconds=nil)
|
16
|
+
def self.build(stream_name, frequency_milliseconds=nil)
|
17
17
|
frequency_milliseconds ||= Defaults.frequency_milliseconds
|
18
18
|
|
19
|
-
new(frequency_milliseconds)
|
19
|
+
new(stream_name, frequency_milliseconds)
|
20
20
|
end
|
21
21
|
|
22
22
|
def batch_size
|
23
23
|
Defaults.batch_size
|
24
24
|
end
|
25
25
|
|
26
|
-
def call(
|
26
|
+
def call(position)
|
27
27
|
position ||= 0
|
28
28
|
|
29
29
|
sleep(frequency_seconds)
|
30
30
|
|
31
31
|
batch_size.times.map do |offset|
|
32
|
-
MessageData.
|
32
|
+
MessageData.example(
|
33
33
|
stream_name,
|
34
34
|
position + offset,
|
35
35
|
offset
|
@@ -48,7 +48,7 @@ module Consumer
|
|
48
48
|
end
|
49
49
|
|
50
50
|
class MessageData
|
51
|
-
def self.
|
51
|
+
def self.example(stream_name, global_position, position)
|
52
52
|
data = {
|
53
53
|
:position => position,
|
54
54
|
:global_position => global_position
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module PositionStore
|
4
|
-
class
|
4
|
+
class File
|
5
5
|
include Consumer::PositionStore
|
6
6
|
include Initializer
|
7
7
|
|
@@ -14,18 +14,18 @@ module Consumer
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get
|
17
|
-
return 0 unless File.exist?(path)
|
17
|
+
return 0 unless ::File.exist?(path)
|
18
18
|
|
19
|
-
text = File.read(path)
|
19
|
+
text = ::File.read(path)
|
20
20
|
text.to_i
|
21
21
|
end
|
22
22
|
|
23
23
|
def put(position)
|
24
|
-
File.write(path, position)
|
24
|
+
::File.write(path, position)
|
25
25
|
end
|
26
26
|
|
27
27
|
def path
|
28
|
-
path = File.join('tmp', 'local_file_position_store')
|
28
|
+
path = ::File.join('tmp', 'local_file_position_store')
|
29
29
|
|
30
30
|
unless identifier.nil?
|
31
31
|
path << "-#{identifier}"
|
@@ -1,16 +1,10 @@
|
|
1
1
|
module Consumer
|
2
2
|
module Controls
|
3
3
|
module Subscription
|
4
|
-
def self.example(
|
5
|
-
|
4
|
+
def self.example(stream_name: nil, next_batch: nil, position: nil, batch_size: nil, count: nil)
|
5
|
+
get = Get.example(stream_name: stream_name, batch_size: batch_size, count: count)
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
unless batch.nil?
|
10
|
-
get.set_batch(stream_name, batch, position)
|
11
|
-
end
|
12
|
-
|
13
|
-
subscription = ::Consumer::Subscription.new(stream_name, get)
|
7
|
+
subscription = ::Consumer::Subscription.new(get)
|
14
8
|
|
15
9
|
subscription.position = position if position
|
16
10
|
|
@@ -8,7 +8,7 @@ module Consumer
|
|
8
8
|
|
9
9
|
configure :subscription
|
10
10
|
|
11
|
-
initializer :
|
11
|
+
initializer :get
|
12
12
|
|
13
13
|
attr_accessor :next_batch
|
14
14
|
|
@@ -23,11 +23,11 @@ module Consumer
|
|
23
23
|
|
24
24
|
dependency :poll, Poll
|
25
25
|
|
26
|
-
def self.build(
|
26
|
+
def self.build(get, position: nil, poll_interval_milliseconds: nil)
|
27
27
|
poll_interval_milliseconds ||= Defaults.poll_interval_milliseconds
|
28
28
|
poll_timeout_milliseconds = Defaults.poll_timeout_milliseconds
|
29
29
|
|
30
|
-
instance = new(
|
30
|
+
instance = new(get)
|
31
31
|
|
32
32
|
instance.position = position
|
33
33
|
|
@@ -46,20 +46,20 @@ module Consumer
|
|
46
46
|
end
|
47
47
|
|
48
48
|
handle :resupply do
|
49
|
-
logger.trace { "Resupplying (
|
49
|
+
logger.trace { "Resupplying (Stream Name: #{get.stream_name}, Position: #{position})" }
|
50
50
|
|
51
51
|
batch = poll.() do
|
52
|
-
get.(
|
52
|
+
get.(position)
|
53
53
|
end
|
54
54
|
|
55
55
|
if batch.nil? || batch.empty?
|
56
|
-
logger.debug { "Did not resupply; no events available (
|
56
|
+
logger.debug { "Did not resupply; no events available (Stream Name: #{get.stream_name}, Position: #{position})" }
|
57
57
|
|
58
58
|
:resupply
|
59
59
|
else
|
60
60
|
self.next_batch = batch
|
61
61
|
|
62
|
-
logger.debug { "Resupplied (
|
62
|
+
logger.debug { "Resupplied (Stream Name: #{get.stream_name}, Position: #{position}, Batch Size: #{batch.count})" }
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
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: 1.0.
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2019-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ntl-actor
|
@@ -121,7 +121,7 @@ files:
|
|
121
121
|
- lib/consumer/controls/poll.rb
|
122
122
|
- lib/consumer/controls/position.rb
|
123
123
|
- lib/consumer/controls/position_store.rb
|
124
|
-
- lib/consumer/controls/position_store/
|
124
|
+
- lib/consumer/controls/position_store/file.rb
|
125
125
|
- lib/consumer/controls/session.rb
|
126
126
|
- lib/consumer/controls/stream_name.rb
|
127
127
|
- lib/consumer/controls/subscription.rb
|
@@ -155,8 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
- !ruby/object:Gem::Version
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
|
-
|
159
|
-
rubygems_version: 2.7.3
|
158
|
+
rubygems_version: 3.0.1
|
160
159
|
signing_key:
|
161
160
|
specification_version: 4
|
162
161
|
summary: Continuous subscription to a stream and message dispatching to handlers
|