evt-consumer 2.2.0.0 → 2.2.0.1

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: d005131cba1d68a95028facee2e86fb2936e29ae0fe296a746f4e0e25abfc910
4
- data.tar.gz: caf16c231eb6195749b4b2190843ab87aed7735f4fd3b3da72555bab45f8ea76
3
+ metadata.gz: f5fba37af84ef2dfb56fda8f9a02664510d0fe78cd60294fdb0fb1ccbb6b599b
4
+ data.tar.gz: 75ee1350ef0c083527936e22dcea545af051d815d58a033e987188a974a3f02e
5
5
  SHA512:
6
- metadata.gz: 332338327a4a4fc99a3010e1e62b0dd840d64914efba85d3f90a22a001df3215c43f49933b213ac6ae7bef78dfe2018b3cb6dcf051c40b42eb278e5d547dd0a8
7
- data.tar.gz: 76e5105a629fbd97447d2423139b08ecf1d33a1cdb513bc662cacf3e4ec969888ee2b3da677fdc009583490f313d9067effac3e1c9087ee074ff9760d2bca24a
6
+ metadata.gz: c94763f577b956fafebd263bcf40cf82362a8010c1c026c96fc70e7072fc81d10c6443ba8b7bda872ac65f682f080a633387cfb1bdb882c64586825a4cd7e030
7
+ data.tar.gz: 42fa7d3fe8985a7bb808ab7eafa9883fa236cc2edb76c1bfe8da657f400390cc891970fb0f32b78d3553620e57bce2b46216723cc48776ede7131080f1b4f50f
@@ -33,10 +33,10 @@ module Consumer
33
33
  @position_update_counter ||= 0
34
34
  end
35
35
 
36
- attr_accessor :session
37
-
38
36
  attr_accessor :poll_interval_milliseconds
39
37
 
38
+ attr_accessor :session
39
+
40
40
  dependency :get, MessageStore::Get
41
41
  dependency :position_store, PositionStore
42
42
  dependency :subscription, Subscription
@@ -49,34 +49,20 @@ module Consumer
49
49
  end
50
50
  end
51
51
 
52
- def dispatch(message_data)
53
- logger.trace { "Dispatching message (#{LogText.message_data(message_data)})" }
52
+ def start(&probe)
53
+ logger.info(tags: [:consumer, :start]) { "Starting consumer: #{self.class.name} (Category: #{category}, Identifier: #{identifier || '(none)'}, Position: #{subscription.position})" }
54
54
 
55
- self.class.handler_registry.each do |handler|
56
- handler.(message_data, session: session)
55
+ if Defaults.startup_info?
56
+ print_info
57
57
  end
58
58
 
59
- update_position(message_data.global_position)
60
-
61
- logger.info { "Message dispatched (#{LogText.message_data(message_data)})" }
62
- rescue => error
63
- logger.error { "Error raised (Error Class: #{error.class}, Error Message: #{error.message}, #{LogText.message_data(message_data)})" }
64
- error_raised(error, message_data)
65
- end
66
-
67
- def start(&probe)
68
- logger.info(tag: :*) { "Starting consumer: #{self.class.name} (Category: #{category}, Identifier: #{identifier || '(none)'}, Position: #{subscription.position})" }
59
+ log_info
60
+ starting if respond_to?(:starting)
69
61
 
70
62
  if not MessageStore::StreamName.category?(category)
71
63
  raise Error, "Consumer's stream name must be a category (Stream Name: #{category})"
72
64
  end
73
65
 
74
- starting() if respond_to?(:starting)
75
-
76
- self.class.handler_registry.each do |handler|
77
- logger.info(tag: :*) { "Handler: #{handler.name} (Category: #{category}, Consumer: #{self.class.name})" }
78
- end
79
-
80
66
  _, subscription_thread = ::Actor::Start.(subscription)
81
67
 
82
68
  actor_address, actor_thread = Actor.start(self, subscription, include: :thread)
@@ -87,24 +73,76 @@ module Consumer
87
73
  probe.(self, [actor_thread, subscription_thread], [actor_address, subscription_address])
88
74
  end
89
75
 
90
- logger.info(tag: :*) { "Started consumer: #{self.class.name} (Category: #{category}, Identifier: #{identifier || '(none)'}, Position: #{subscription.position})" }
76
+ logger.info(tags: [:consumer, :start]) { "Started consumer: #{self.class.name} (Category: #{category}, Identifier: #{identifier || '(none)'}, Position: #{subscription.position})" }
91
77
 
92
78
  AsyncInvocation::Incorrect
93
79
  end
94
80
 
81
+ def print_info
82
+ STDOUT.puts
83
+ STDOUT.puts " Consumer: #{self.class.name}"
84
+ STDOUT.puts " Category: #{category}"
85
+ STDOUT.puts " Position: #{subscription.position}"
86
+ STDOUT.puts " Identifier: #{identifier || '(none)'}"
87
+
88
+ print_startup_info if respond_to?(:print_startup_info)
89
+
90
+ STDOUT.puts " Position Stream: #{position_store.stream_name}"
91
+
92
+ STDOUT.puts
93
+
94
+ STDOUT.puts " Handlers:"
95
+ self.class.handler_registry.each do |handler|
96
+ STDOUT.puts " Handler: #{handler.name}"
97
+ STDOUT.puts " Messages: #{handler.message_registry.message_types.join(', ')}"
98
+ end
99
+ end
100
+
101
+ def log_info
102
+ logger.info(tags: [:consumer, :start]) { "Category: #{category} (Consumer: #{self.class.name})" }
103
+ logger.info(tags: [:consumer, :start]) { "Position: #{subscription.position} (Consumer: #{self.class.name})" }
104
+ logger.info(tags: [:consumer, :start]) { "Identifier: #{identifier || 'nil'} (Consumer: #{self.class.name})" }
105
+
106
+ log_startup_info if respond_to?(:log_startup_info)
107
+
108
+ logger.info(tags: [:consumer, :start]) { "Position Update Interval: #{position_update_interval.inspect} (Consumer: #{self.class.name})" }
109
+
110
+ logger.info(tags: [:consumer, :start]) { "Poll Interval Milliseconds: #{poll_interval_milliseconds.inspect} (Consumer: #{self.class.name})" }
111
+
112
+ self.class.handler_registry.each do |handler|
113
+ logger.info(tags: [:consumer, :start]) { "Handler: #{handler.name} (Consumer: #{self.class.name})" }
114
+ logger.info(tags: [:consumer, :start]) { "Messages: #{handler.message_registry.message_types.join(', ')} (Handler: #{handler.name}, Consumer: #{self.class.name})" }
115
+ end
116
+ end
117
+
118
+ def dispatch(message_data)
119
+ logger.trace(tags: [:consumer, :dispatch, :message]) { "Dispatching message (#{LogText.message_data(message_data)})" }
120
+
121
+ self.class.handler_registry.each do |handler|
122
+ handler.(message_data, session: session)
123
+ end
124
+
125
+ update_position(message_data.global_position)
126
+
127
+ logger.debug(tags: [:consumer, :dispatch, :message]) { "Message dispatched (#{LogText.message_data(message_data)})" }
128
+ rescue => error
129
+ logger.error(tag: :*) { "Error raised (Error Class: #{error.class}, Error Message: #{error.message}, #{LogText.message_data(message_data)})" }
130
+ error_raised(error, message_data)
131
+ end
132
+
95
133
  def update_position(position)
96
- logger.trace { "Updating position (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
134
+ logger.trace(tags: [:consumer, :position]) { "Updating position (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
97
135
 
98
136
  self.position_update_counter += 1
99
137
 
100
138
  if position_update_counter >= position_update_interval
101
139
  position_store.put(position)
102
140
 
103
- logger.debug { "Updated position (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
141
+ logger.debug(tags: [:consumer, :position]) { "Updated position (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
104
142
 
105
143
  self.position_update_counter = 0
106
144
  else
107
- logger.debug { "Interval not reached; position not updated (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
145
+ logger.debug(tags: [:consumer, :position]) { "Interval not reached; position not updated (Global Position: #{position}, Counter: #{position_update_counter}/#{position_update_interval})" }
108
146
  end
109
147
  end
110
148
 
@@ -116,7 +154,7 @@ module Consumer
116
154
 
117
155
  module Configure
118
156
  def configure(**kwargs)
119
- logger.trace { "Configuring (Category: #{category})" }
157
+ logger.trace(tag: :consumer) { "Configuring (Category: #{category})" }
120
158
 
121
159
  super(**kwargs)
122
160
 
@@ -129,7 +167,7 @@ module Consumer
129
167
  poll_interval_milliseconds: poll_interval_milliseconds
130
168
  )
131
169
 
132
- logger.debug { "Done configuring (Category: #{category}, Starting Position: #{starting_position})" }
170
+ logger.debug(tag: :consumer) { "Done configuring (Category: #{category}, Starting Position: #{starting_position})" }
133
171
  end
134
172
  end
135
173
 
@@ -185,4 +223,24 @@ module Consumer
185
223
  end
186
224
  end
187
225
  end
226
+
227
+ module Defaults
228
+ def self.startup_info?
229
+ StartupInfo.get == 'on'
230
+ end
231
+
232
+ module StartupInfo
233
+ def self.get
234
+ ENV.fetch(env_var, default)
235
+ end
236
+
237
+ def self.env_var
238
+ 'STARTUP_INFO'
239
+ end
240
+
241
+ def self.default
242
+ 'on'
243
+ end
244
+ end
245
+ end
188
246
  end
@@ -10,6 +10,10 @@ module Consumer
10
10
 
11
11
  attr_accessor :telemetry_sink
12
12
 
13
+ def stream_name
14
+ 'somePositionStream'
15
+ end
16
+
13
17
  def self.build
14
18
  instance = new
15
19
  instance.configure
@@ -60,7 +60,7 @@ module Consumer
60
60
 
61
61
  position = super
62
62
 
63
- logger.info(tags: [:position_store, :get]) { "Get position done (Position: #{position || '(none)'})" }
63
+ logger.debug(tags: [:position_store, :get]) { "Get position done (Position: #{position || '(none)'})" }
64
64
 
65
65
  telemetry.record(:get, Telemetry::Get.new(position))
66
66
 
@@ -0,0 +1 @@
1
+ lib/consumer/Users/sbellware/projects/eventide/consumer-postgres/lib/consumer/postgres
@@ -0,0 +1 @@
1
+ lib/consumer/Users/sbellware/projects/eventide/consumer-postgres/lib/consumer/postgres.rb
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: 2.2.0.0
4
+ version: 2.2.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: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ntl-actor
@@ -132,6 +132,8 @@ files:
132
132
  - lib/consumer/position_store.rb
133
133
  - lib/consumer/position_store/substitute.rb
134
134
  - lib/consumer/position_store/telemetry.rb
135
+ - lib/consumer/postgres
136
+ - lib/consumer/postgres.rb
135
137
  - lib/consumer/subscription.rb
136
138
  - lib/consumer/subscription/defaults.rb
137
139
  - lib/consumer/subscription/get_batch.rb
@@ -155,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
157
  - !ruby/object:Gem::Version
156
158
  version: '0'
157
159
  requirements: []
158
- rubygems_version: 3.0.1
160
+ rubygems_version: 3.1.2
159
161
  signing_key:
160
162
  specification_version: 4
161
163
  summary: Continuous subscription to a category and message dispatching to handlers