evt-consumer 1.0.2.0 → 1.1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 901e1a9d91cca556f4765a4f7f1a94891fd6d94f8446063279a318686d61f4de
4
- data.tar.gz: 907ef3a3db796e3a97a5e2d08880ae5063da536f1b5ca8aa62ea64865be26628
3
+ metadata.gz: 2077ef49032cd7e88e66307072188bd14f3f5eb60c3889d3eaa2d8e32d398a91
4
+ data.tar.gz: db192f1c6a7d6c7629200fdb71152d325ec05fcd27f1acf17d2f6f7a77088a77
5
5
  SHA512:
6
- metadata.gz: f5b5098d77dad10ffb7fc2d74e6ed969625b812e117b0c00b20673964e83276b4b45820bc53048e7c1d77d0398cfdb21f4e6949f4c48129ec7ae9cc383af7e78
7
- data.tar.gz: 219e380a4eb82f77950d5eeeee3a38dd426510f09213661ffbb9959eb428f96bccc0e830f28072fb88bd8fb7c5d7a5f0c836eb26f601fbbb1d9f1b0c48571be5
6
+ metadata.gz: e80126fd3557847a29603838d917b11fbdc93b617cca9ac17ea2c68471d6c1cef76c9e15656a306bf4959ff6ea80f9615db120fb8c72d37ca8096b3c2ed5c187
7
+ data.tar.gz: 4c64c89911619b136db60fc135619c17573410083ce86cf0fc4438254133b8bd1724f0123536393f58b783830a60c46248ba2cf62f58b96b8d4dd0852d52dcfd
@@ -119,7 +119,6 @@ module Consumer
119
119
 
120
120
  Subscription.configure(
121
121
  self,
122
- stream_name,
123
122
  get,
124
123
  position: starting_position,
125
124
  poll_interval_milliseconds: poll_interval_milliseconds
@@ -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/local_file'
17
+ require 'consumer/controls/position_store/file'
18
18
  require 'consumer/controls/subscription'
19
19
 
20
20
  require 'consumer/controls/handle'
@@ -10,7 +10,7 @@ module Consumer
10
10
 
11
11
  module DelayThreshold
12
12
  def self.example
13
- Get.default_batch_size
13
+ 11
14
14
  end
15
15
  end
16
16
 
@@ -39,7 +39,8 @@ module Consumer
39
39
  def configure(settings: nil, **)
40
40
  Controls::Session::Example.configure(self, settings)
41
41
 
42
- Get::Example.configure(self)
42
+ self.get = Get.example
43
+
43
44
  PositionStore::Example.configure(self)
44
45
  end
45
46
 
@@ -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::LocalFile.configure(self, identifier: identifier)
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
- module Get
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(stream_name, position: nil)
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.get(
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.get(stream_name, global_position, position)
51
+ def self.example(stream_name, global_position, position)
52
52
  data = {
53
53
  :position => position,
54
54
  :global_position => global_position
@@ -13,6 +13,8 @@ module Consumer
13
13
 
14
14
  message_data
15
15
  end
16
+
17
+ Write = MessageStore::Controls::MessageData::Write
16
18
  end
17
19
  end
18
20
  end
@@ -11,9 +11,11 @@ module Consumer
11
11
  def self.example(offset: nil)
12
12
  offset ||= 0
13
13
 
14
- position = MessageStore::Controls::MessageData::Read.global_position
14
+ start + offset
15
+ end
15
16
 
16
- position + offset
17
+ def self.start
18
+ 11
17
19
  end
18
20
  end
19
21
  end
@@ -1,7 +1,7 @@
1
1
  module Consumer
2
2
  module Controls
3
3
  module PositionStore
4
- class LocalFile
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(next_batch: nil, batch: nil, position: nil, batch_size: nil)
5
- stream_name = StreamName.example
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
- get = Get.example(batch_size: batch_size)
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 :stream_name, :get
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(stream_name, get, position: nil, poll_interval_milliseconds: nil)
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(stream_name, get)
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 (StreamName: #{stream_name}, Position: #{position})" }
49
+ logger.trace { "Resupplying (Stream Name: #{get.stream_name}, Position: #{position})" }
50
50
 
51
51
  batch = poll.() do
52
- get.(stream_name, position: position)
52
+ get.(position)
53
53
  end
54
54
 
55
55
  if batch.nil? || batch.empty?
56
- logger.debug { "Did not resupply; no events available (StreamName: #{stream_name}, Position: #{position})" }
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 (StreamName: #{stream_name}, Position: #{position}, Batch Size: #{batch.count})" }
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.2.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: 2018-12-30 00:00:00.000000000 Z
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/local_file.rb
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
- rubyforge_project:
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