phobos 2.1.4 → 2.1.6
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 +4 -4
- data/.gitattributes +4 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/bin/tapioca +29 -0
- data/defs.rbi +740 -0
- data/lib/phobos/batch_handler.rb +11 -0
- data/lib/phobos/batch_message.rb +18 -1
- data/lib/phobos/cli.rb +3 -1
- data/lib/phobos/configuration.rb +3 -1
- data/lib/phobos/handler.rb +1 -0
- data/lib/phobos/listener.rb +24 -3
- data/lib/phobos/producer.rb +44 -2
- data/lib/phobos/version.rb +2 -1
- data/lib/phobos.rb +12 -1
- data/phobos.gemspec +5 -1
- data/rbi/defs.rbi +601 -0
- metadata +63 -3
data/defs.rbi
ADDED
@@ -0,0 +1,740 @@
|
|
1
|
+
# typed: strong
|
2
|
+
# Please use this with at least the same consideration as you would when using OpenStruct.
|
3
|
+
# Right now we only use this to parse our internal configuration files. It is not meant to
|
4
|
+
# be used on incoming data.
|
5
|
+
module Phobos
|
6
|
+
extend Phobos::Configuration
|
7
|
+
VERSION = T.let('2.1.4', T.untyped)
|
8
|
+
|
9
|
+
class << self
|
10
|
+
sig { returns(Phobos::DeepStruct) }
|
11
|
+
attr_reader :config
|
12
|
+
|
13
|
+
sig { returns(Logger) }
|
14
|
+
attr_reader :logger
|
15
|
+
|
16
|
+
sig { returns(T::Boolean) }
|
17
|
+
attr_accessor :silence_log
|
18
|
+
end
|
19
|
+
|
20
|
+
# _@param_ `configuration`
|
21
|
+
sig { params(configuration: T::Hash[String, Object]).void }
|
22
|
+
def self.add_listeners(configuration); end
|
23
|
+
|
24
|
+
# sord omit - no YARD return type given, using untyped
|
25
|
+
# _@param_ `config_key`
|
26
|
+
sig { params(config_key: T.nilable(String)).returns(T.untyped) }
|
27
|
+
def self.create_kafka_client(config_key = nil); end
|
28
|
+
|
29
|
+
# sord omit - no YARD return type given, using untyped
|
30
|
+
# _@param_ `backoff_config`
|
31
|
+
sig { params(backoff_config: T.nilable(T::Hash[Symbol, Integer])).returns(T.untyped) }
|
32
|
+
def self.create_exponential_backoff(backoff_config = nil); end
|
33
|
+
|
34
|
+
# _@param_ `message`
|
35
|
+
sig { params(message: String).void }
|
36
|
+
def self.deprecate(message); end
|
37
|
+
|
38
|
+
# _@param_ `configuration`
|
39
|
+
sig { params(configuration: T.untyped).void }
|
40
|
+
def self.configure(configuration); end
|
41
|
+
|
42
|
+
sig { void }
|
43
|
+
def self.configure_logger; end
|
44
|
+
|
45
|
+
module Log
|
46
|
+
# sord omit - no YARD type given for "msg", using untyped
|
47
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
48
|
+
# sord omit - no YARD return type given, using untyped
|
49
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
50
|
+
def log_info(msg, metadata = {}); end
|
51
|
+
|
52
|
+
# sord omit - no YARD type given for "msg", using untyped
|
53
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
54
|
+
# sord omit - no YARD return type given, using untyped
|
55
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
56
|
+
def log_debug(msg, metadata = {}); end
|
57
|
+
|
58
|
+
# sord omit - no YARD type given for "msg", using untyped
|
59
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
60
|
+
# sord omit - no YARD return type given, using untyped
|
61
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
62
|
+
def log_error(msg, metadata); end
|
63
|
+
|
64
|
+
# sord omit - no YARD type given for "msg", using untyped
|
65
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
66
|
+
# sord omit - no YARD return type given, using untyped
|
67
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
68
|
+
def log_warn(msg, metadata = {}); end
|
69
|
+
end
|
70
|
+
|
71
|
+
module LoggerHelper
|
72
|
+
# sord omit - no YARD type given for "method", using untyped
|
73
|
+
# sord omit - no YARD type given for "msg", using untyped
|
74
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
75
|
+
# sord omit - no YARD return type given, using untyped
|
76
|
+
sig { params(method: T.untyped, msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
77
|
+
def self.log(method, msg, metadata); end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Error < StandardError
|
81
|
+
end
|
82
|
+
|
83
|
+
class AbortError < Phobos::Error
|
84
|
+
end
|
85
|
+
|
86
|
+
module Handler
|
87
|
+
# sord omit - no YARD type given for "_payload", using untyped
|
88
|
+
# sord omit - no YARD type given for "_metadata", using untyped
|
89
|
+
# sord omit - no YARD return type given, using untyped
|
90
|
+
sig { params(_payload: T.untyped, _metadata: T.untyped).returns(T.untyped) }
|
91
|
+
def consume(_payload, _metadata); end
|
92
|
+
|
93
|
+
# sord omit - no YARD type given for "payload", using untyped
|
94
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
95
|
+
# sord omit - no YARD return type given, using untyped
|
96
|
+
sig { params(payload: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
97
|
+
def around_consume(payload, metadata); end
|
98
|
+
|
99
|
+
module ClassMethods
|
100
|
+
# sord omit - no YARD type given for "kafka_client", using untyped
|
101
|
+
# sord omit - no YARD return type given, using untyped
|
102
|
+
sig { params(kafka_client: T.untyped).returns(T.untyped) }
|
103
|
+
def start(kafka_client); end
|
104
|
+
|
105
|
+
# sord omit - no YARD return type given, using untyped
|
106
|
+
sig { returns(T.untyped) }
|
107
|
+
def stop; end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class Executor
|
112
|
+
include Phobos::Instrumentation
|
113
|
+
include Phobos::Log
|
114
|
+
|
115
|
+
sig { void }
|
116
|
+
def initialize; end
|
117
|
+
|
118
|
+
# sord omit - no YARD return type given, using untyped
|
119
|
+
sig { returns(T.untyped) }
|
120
|
+
def start; end
|
121
|
+
|
122
|
+
# sord omit - no YARD return type given, using untyped
|
123
|
+
sig { returns(T.untyped) }
|
124
|
+
def stop; end
|
125
|
+
|
126
|
+
# sord omit - no YARD type given for "msg", using untyped
|
127
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
128
|
+
# sord omit - no YARD return type given, using untyped
|
129
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
130
|
+
def log_info(msg, metadata = {}); end
|
131
|
+
|
132
|
+
# sord omit - no YARD type given for "msg", using untyped
|
133
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
134
|
+
# sord omit - no YARD return type given, using untyped
|
135
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
136
|
+
def log_debug(msg, metadata = {}); end
|
137
|
+
|
138
|
+
# sord omit - no YARD type given for "msg", using untyped
|
139
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
140
|
+
# sord omit - no YARD return type given, using untyped
|
141
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
142
|
+
def log_error(msg, metadata); end
|
143
|
+
|
144
|
+
# sord omit - no YARD type given for "msg", using untyped
|
145
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
146
|
+
# sord omit - no YARD return type given, using untyped
|
147
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
148
|
+
def log_warn(msg, metadata = {}); end
|
149
|
+
|
150
|
+
# sord omit - no YARD type given for "event", using untyped
|
151
|
+
# sord omit - no YARD type given for "extra", using untyped
|
152
|
+
# sord omit - no YARD return type given, using untyped
|
153
|
+
sig { params(event: T.untyped, extra: T.untyped).returns(T.untyped) }
|
154
|
+
def instrument(event, extra = {}); end
|
155
|
+
end
|
156
|
+
|
157
|
+
# rubocop:disable Metrics/ParameterLists, Metrics/ClassLength
|
158
|
+
class Listener
|
159
|
+
include Phobos::Instrumentation
|
160
|
+
include Phobos::Log
|
161
|
+
DEFAULT_MAX_BYTES_PER_PARTITION = T.let(1_048_576, T.untyped)
|
162
|
+
DELIVERY_OPTS = T.let(%w[batch message inline_batch].freeze, T.untyped)
|
163
|
+
|
164
|
+
# sord omit - no YARD type given for "force_encoding:", using untyped
|
165
|
+
# sord omit - no YARD type given for "backoff:", using untyped
|
166
|
+
# rubocop:disable Metrics/MethodLength
|
167
|
+
#
|
168
|
+
# _@param_ `handler`
|
169
|
+
#
|
170
|
+
# _@param_ `group_id`
|
171
|
+
#
|
172
|
+
# _@param_ `topic`
|
173
|
+
#
|
174
|
+
# _@param_ `min_bytes`
|
175
|
+
#
|
176
|
+
# _@param_ `max_wait_time`
|
177
|
+
#
|
178
|
+
# _@param_ `start_from_beginning`
|
179
|
+
#
|
180
|
+
# _@param_ `delivery`
|
181
|
+
#
|
182
|
+
# _@param_ `max_bytes_per_partition`
|
183
|
+
#
|
184
|
+
# _@param_ `session_timeout`
|
185
|
+
#
|
186
|
+
# _@param_ `offset_commit_interval`
|
187
|
+
#
|
188
|
+
# _@param_ `heartbeat_interval`
|
189
|
+
#
|
190
|
+
# _@param_ `offset_commit_threshold`
|
191
|
+
#
|
192
|
+
# _@param_ `offset_retention_time`
|
193
|
+
sig do
|
194
|
+
params(
|
195
|
+
handler: T.class_of(BasicObject),
|
196
|
+
group_id: String,
|
197
|
+
topic: String,
|
198
|
+
min_bytes: T.nilable(Integer),
|
199
|
+
max_wait_time: T.nilable(Integer),
|
200
|
+
force_encoding: T.untyped,
|
201
|
+
start_from_beginning: T::Boolean,
|
202
|
+
backoff: T.untyped,
|
203
|
+
delivery: String,
|
204
|
+
max_bytes_per_partition: Integer,
|
205
|
+
session_timeout: T.nilable(Integer),
|
206
|
+
offset_commit_interval: T.nilable(Integer),
|
207
|
+
heartbeat_interval: T.nilable(Integer),
|
208
|
+
offset_commit_threshold: T.nilable(Integer),
|
209
|
+
offset_retention_time: T.nilable(Integer)
|
210
|
+
).void
|
211
|
+
end
|
212
|
+
def initialize(handler:, group_id:, topic:, min_bytes: nil, max_wait_time: nil, force_encoding: nil, start_from_beginning: true, backoff: nil, delivery: 'batch', max_bytes_per_partition: DEFAULT_MAX_BYTES_PER_PARTITION, session_timeout: nil, offset_commit_interval: nil, heartbeat_interval: nil, offset_commit_threshold: nil, offset_retention_time: nil); end
|
213
|
+
|
214
|
+
sig { void }
|
215
|
+
def start; end
|
216
|
+
|
217
|
+
sig { void }
|
218
|
+
def stop; end
|
219
|
+
|
220
|
+
# sord omit - no YARD return type given, using untyped
|
221
|
+
sig { returns(T.untyped) }
|
222
|
+
def create_exponential_backoff; end
|
223
|
+
|
224
|
+
sig { returns(T::Boolean) }
|
225
|
+
def should_stop?; end
|
226
|
+
|
227
|
+
# sord omit - no YARD return type given, using untyped
|
228
|
+
sig { returns(T.untyped) }
|
229
|
+
def send_heartbeat_if_necessary; end
|
230
|
+
|
231
|
+
# sord omit - no YARD type given for "msg", using untyped
|
232
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
233
|
+
# sord omit - no YARD return type given, using untyped
|
234
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
235
|
+
def log_info(msg, metadata = {}); end
|
236
|
+
|
237
|
+
# sord omit - no YARD type given for "msg", using untyped
|
238
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
239
|
+
# sord omit - no YARD return type given, using untyped
|
240
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
241
|
+
def log_debug(msg, metadata = {}); end
|
242
|
+
|
243
|
+
# sord omit - no YARD type given for "msg", using untyped
|
244
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
245
|
+
# sord omit - no YARD return type given, using untyped
|
246
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
247
|
+
def log_error(msg, metadata); end
|
248
|
+
|
249
|
+
# sord omit - no YARD type given for "msg", using untyped
|
250
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
251
|
+
# sord omit - no YARD return type given, using untyped
|
252
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
253
|
+
def log_warn(msg, metadata = {}); end
|
254
|
+
|
255
|
+
# sord omit - no YARD type given for "event", using untyped
|
256
|
+
# sord omit - no YARD type given for "extra", using untyped
|
257
|
+
# sord omit - no YARD return type given, using untyped
|
258
|
+
sig { params(event: T.untyped, extra: T.untyped).returns(T.untyped) }
|
259
|
+
def instrument(event, extra = {}); end
|
260
|
+
|
261
|
+
sig { returns(String) }
|
262
|
+
attr_reader :group_id
|
263
|
+
|
264
|
+
sig { returns(String) }
|
265
|
+
attr_reader :topic
|
266
|
+
|
267
|
+
# sord omit - no YARD type given for :id, using untyped
|
268
|
+
# Returns the value of attribute id.
|
269
|
+
sig { returns(T.untyped) }
|
270
|
+
attr_reader :id
|
271
|
+
|
272
|
+
sig { returns(T.class_of(BasicObject)) }
|
273
|
+
attr_reader :handler_class
|
274
|
+
|
275
|
+
# sord omit - no YARD type given for :encoding, using untyped
|
276
|
+
# Returns the value of attribute encoding.
|
277
|
+
sig { returns(T.untyped) }
|
278
|
+
attr_reader :encoding
|
279
|
+
|
280
|
+
# sord omit - no YARD type given for :consumer, using untyped
|
281
|
+
# Returns the value of attribute consumer.
|
282
|
+
sig { returns(T.untyped) }
|
283
|
+
attr_reader :consumer
|
284
|
+
end
|
285
|
+
|
286
|
+
module Producer
|
287
|
+
sig { returns(Phobos::Producer::PublicAPI) }
|
288
|
+
def producer; end
|
289
|
+
|
290
|
+
class PublicAPI
|
291
|
+
# sord omit - no YARD type given for "host_obj", using untyped
|
292
|
+
sig { params(host_obj: T.untyped).void }
|
293
|
+
def initialize(host_obj); end
|
294
|
+
|
295
|
+
# _@param_ `topic`
|
296
|
+
#
|
297
|
+
# _@param_ `payload`
|
298
|
+
#
|
299
|
+
# _@param_ `key`
|
300
|
+
#
|
301
|
+
# _@param_ `partition_key`
|
302
|
+
#
|
303
|
+
# _@param_ `headers`
|
304
|
+
sig do
|
305
|
+
params(
|
306
|
+
topic: String,
|
307
|
+
payload: String,
|
308
|
+
key: T.nilable(String),
|
309
|
+
partition_key: T.nilable(Integer),
|
310
|
+
headers: T.nilable(T::Hash[T.untyped, T.untyped])
|
311
|
+
).void
|
312
|
+
end
|
313
|
+
def publish(topic:, payload:, key: nil, partition_key: nil, headers: nil); end
|
314
|
+
|
315
|
+
# _@param_ `topic`
|
316
|
+
#
|
317
|
+
# _@param_ `payload`
|
318
|
+
#
|
319
|
+
# _@param_ `key`
|
320
|
+
#
|
321
|
+
# _@param_ `partition_key`
|
322
|
+
#
|
323
|
+
# _@param_ `headers`
|
324
|
+
sig do
|
325
|
+
params(
|
326
|
+
topic: String,
|
327
|
+
payload: String,
|
328
|
+
key: T.nilable(String),
|
329
|
+
partition_key: T.nilable(Integer),
|
330
|
+
headers: T.nilable(T::Hash[T.untyped, T.untyped])
|
331
|
+
).void
|
332
|
+
end
|
333
|
+
def async_publish(topic:, payload:, key: nil, partition_key: nil, headers: nil); end
|
334
|
+
|
335
|
+
# sord omit - no YARD return type given, using untyped
|
336
|
+
# _@param_ `messages` — e.g.: [ { topic: 'A', payload: 'message-1', key: '1', headers: { foo: 'bar' } }, { topic: 'B', payload: 'message-2', key: '2', headers: { foo: 'bar' } } ]
|
337
|
+
sig { params(messages: T::Array[T::Hash[T.untyped, T.untyped]]).returns(T.untyped) }
|
338
|
+
def publish_list(messages); end
|
339
|
+
|
340
|
+
# sord omit - no YARD return type given, using untyped
|
341
|
+
# _@param_ `messages`
|
342
|
+
sig { params(messages: T::Array[T::Hash[T.untyped, T.untyped]]).returns(T.untyped) }
|
343
|
+
def async_publish_list(messages); end
|
344
|
+
end
|
345
|
+
|
346
|
+
module ClassMethods
|
347
|
+
sig { returns(Phobos::Producer::ClassMethods::PublicAPI) }
|
348
|
+
def producer; end
|
349
|
+
|
350
|
+
class PublicAPI
|
351
|
+
NAMESPACE = T.let(:phobos_producer_store, T.untyped)
|
352
|
+
ASYNC_PRODUCER_PARAMS = T.let([:max_queue_size, :delivery_threshold, :delivery_interval].freeze, T.untyped)
|
353
|
+
INTERNAL_PRODUCER_PARAMS = T.let([:persistent_connections].freeze, T.untyped)
|
354
|
+
|
355
|
+
# This method configures the kafka client used with publish operations
|
356
|
+
# performed by the host class
|
357
|
+
#
|
358
|
+
# _@param_ `kafka_client`
|
359
|
+
sig { params(kafka_client: Kafka::Client).void }
|
360
|
+
def configure_kafka_client(kafka_client); end
|
361
|
+
|
362
|
+
sig { returns(Kafka::Client) }
|
363
|
+
def kafka_client; end
|
364
|
+
|
365
|
+
sig { returns(Kafka::Producer) }
|
366
|
+
def create_sync_producer; end
|
367
|
+
|
368
|
+
sig { returns(Kafka::Producer) }
|
369
|
+
def sync_producer; end
|
370
|
+
|
371
|
+
sig { void }
|
372
|
+
def sync_producer_shutdown; end
|
373
|
+
|
374
|
+
# sord omit - no YARD type given for "key:", using untyped
|
375
|
+
# _@param_ `topic`
|
376
|
+
#
|
377
|
+
# _@param_ `payload`
|
378
|
+
#
|
379
|
+
# _@param_ `partition_key`
|
380
|
+
#
|
381
|
+
# _@param_ `headers`
|
382
|
+
sig do
|
383
|
+
params(
|
384
|
+
topic: String,
|
385
|
+
payload: String,
|
386
|
+
key: T.untyped,
|
387
|
+
partition_key: T.nilable(Integer),
|
388
|
+
headers: T.nilable(T::Hash[T.untyped, T.untyped])
|
389
|
+
).void
|
390
|
+
end
|
391
|
+
def publish(topic:, payload:, key: nil, partition_key: nil, headers: nil); end
|
392
|
+
|
393
|
+
# _@param_ `messages`
|
394
|
+
sig { params(messages: T::Array[T::Hash[T.untyped, T.untyped]]).void }
|
395
|
+
def publish_list(messages); end
|
396
|
+
|
397
|
+
sig { returns(Kafka::AsyncProducer) }
|
398
|
+
def create_async_producer; end
|
399
|
+
|
400
|
+
sig { returns(Kafka::AsyncProducer) }
|
401
|
+
def async_producer; end
|
402
|
+
|
403
|
+
# sord omit - no YARD type given for "key:", using untyped
|
404
|
+
# _@param_ `topic`
|
405
|
+
#
|
406
|
+
# _@param_ `payload`
|
407
|
+
#
|
408
|
+
# _@param_ `partition_key`
|
409
|
+
#
|
410
|
+
# _@param_ `headers`
|
411
|
+
sig do
|
412
|
+
params(
|
413
|
+
topic: String,
|
414
|
+
payload: String,
|
415
|
+
key: T.untyped,
|
416
|
+
partition_key: T.nilable(Integer),
|
417
|
+
headers: T.nilable(T::Hash[T.untyped, T.untyped])
|
418
|
+
).void
|
419
|
+
end
|
420
|
+
def async_publish(topic:, payload:, key: nil, partition_key: nil, headers: nil); end
|
421
|
+
|
422
|
+
# _@param_ `messages`
|
423
|
+
sig { params(messages: T::Array[T::Hash[T.untyped, T.untyped]]).void }
|
424
|
+
def async_publish_list(messages); end
|
425
|
+
|
426
|
+
sig { void }
|
427
|
+
def async_producer_shutdown; end
|
428
|
+
|
429
|
+
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
430
|
+
def regular_configs; end
|
431
|
+
|
432
|
+
sig { returns(T::Hash[T.untyped, T.untyped]) }
|
433
|
+
def async_configs; end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
module Constants
|
439
|
+
LOG_DATE_PATTERN = T.let('%Y-%m-%dT%H:%M:%S:%L%zZ', T.untyped)
|
440
|
+
KAFKA_CONSUMER_OPTS = T.let([
|
441
|
+
:session_timeout,
|
442
|
+
:offset_commit_interval,
|
443
|
+
:offset_commit_threshold,
|
444
|
+
:heartbeat_interval,
|
445
|
+
:offset_retention_time
|
446
|
+
].freeze, T.untyped)
|
447
|
+
LISTENER_OPTS = T.let([
|
448
|
+
:handler,
|
449
|
+
:group_id,
|
450
|
+
:topic,
|
451
|
+
:min_bytes,
|
452
|
+
:max_wait_time,
|
453
|
+
:force_encoding,
|
454
|
+
:start_from_beginning,
|
455
|
+
:max_bytes_per_partition,
|
456
|
+
:backoff,
|
457
|
+
:delivery,
|
458
|
+
:session_timeout,
|
459
|
+
:offset_commit_interval,
|
460
|
+
:offset_commit_threshold,
|
461
|
+
:heartbeat_interval,
|
462
|
+
:offset_retention_time
|
463
|
+
].freeze, T.untyped)
|
464
|
+
end
|
465
|
+
|
466
|
+
module Processor
|
467
|
+
include Phobos::Instrumentation
|
468
|
+
extend ActiveSupport::Concern
|
469
|
+
MAX_SLEEP_INTERVAL = T.let(3, T.untyped)
|
470
|
+
|
471
|
+
# sord omit - no YARD type given for "interval", using untyped
|
472
|
+
# sord omit - no YARD return type given, using untyped
|
473
|
+
sig { params(interval: T.untyped).returns(T.untyped) }
|
474
|
+
def snooze(interval); end
|
475
|
+
|
476
|
+
# sord omit - no YARD type given for "event", using untyped
|
477
|
+
# sord omit - no YARD type given for "extra", using untyped
|
478
|
+
# sord omit - no YARD return type given, using untyped
|
479
|
+
sig { params(event: T.untyped, extra: T.untyped).returns(T.untyped) }
|
480
|
+
def instrument(event, extra = {}); end
|
481
|
+
end
|
482
|
+
|
483
|
+
class DeepStruct < OpenStruct
|
484
|
+
# sord omit - no YARD type given for "hash", using untyped
|
485
|
+
# Based on
|
486
|
+
# https://docs.omniref.com/ruby/2.3.0/files/lib/ostruct.rb#line=88
|
487
|
+
sig { params(hash: T.untyped).void }
|
488
|
+
def initialize(hash = nil); end
|
489
|
+
|
490
|
+
# sord omit - no YARD return type given, using untyped
|
491
|
+
sig { returns(T.untyped) }
|
492
|
+
def to_h; end
|
493
|
+
end
|
494
|
+
|
495
|
+
module Test
|
496
|
+
module Helper
|
497
|
+
TOPIC = T.let('test-topic', T.untyped)
|
498
|
+
GROUP = T.let('test-group', T.untyped)
|
499
|
+
|
500
|
+
# sord omit - no YARD type given for "handler:", using untyped
|
501
|
+
# sord omit - no YARD type given for "payload:", using untyped
|
502
|
+
# sord omit - no YARD type given for "metadata:", using untyped
|
503
|
+
# sord omit - no YARD type given for "force_encoding:", using untyped
|
504
|
+
# sord omit - no YARD return type given, using untyped
|
505
|
+
sig do
|
506
|
+
params(
|
507
|
+
handler: T.untyped,
|
508
|
+
payload: T.untyped,
|
509
|
+
metadata: T.untyped,
|
510
|
+
force_encoding: T.untyped
|
511
|
+
).returns(T.untyped)
|
512
|
+
end
|
513
|
+
def process_message(handler:, payload:, metadata: {}, force_encoding: nil); end
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
class EchoHandler
|
518
|
+
include Phobos::Handler
|
519
|
+
|
520
|
+
# sord omit - no YARD type given for "message", using untyped
|
521
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
522
|
+
# sord omit - no YARD return type given, using untyped
|
523
|
+
sig { params(message: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
524
|
+
def consume(message, metadata); end
|
525
|
+
|
526
|
+
# sord omit - no YARD type given for "payload", using untyped
|
527
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
528
|
+
# sord omit - no YARD return type given, using untyped
|
529
|
+
sig { params(payload: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
530
|
+
def around_consume(payload, metadata); end
|
531
|
+
end
|
532
|
+
|
533
|
+
module BatchHandler
|
534
|
+
# _@param_ `_payloads`
|
535
|
+
#
|
536
|
+
# _@param_ `_metadata`
|
537
|
+
sig { params(_payloads: T::Array[T.untyped], _metadata: T::Hash[String, Object]).void }
|
538
|
+
def consume_batch(_payloads, _metadata); end
|
539
|
+
|
540
|
+
# _@param_ `payloads`
|
541
|
+
#
|
542
|
+
# _@param_ `metadata`
|
543
|
+
sig { params(payloads: T::Array[T.untyped], metadata: T::Hash[String, Object]).void }
|
544
|
+
def around_consume_batch(payloads, metadata); end
|
545
|
+
|
546
|
+
module ClassMethods
|
547
|
+
# _@param_ `kafka_client`
|
548
|
+
sig { params(kafka_client: T.untyped).void }
|
549
|
+
def start(kafka_client); end
|
550
|
+
|
551
|
+
sig { void }
|
552
|
+
def stop; end
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
class BatchMessage
|
557
|
+
# _@param_ `key`
|
558
|
+
#
|
559
|
+
# _@param_ `partition`
|
560
|
+
#
|
561
|
+
# _@param_ `offset`
|
562
|
+
#
|
563
|
+
# _@param_ `payload`
|
564
|
+
#
|
565
|
+
# _@param_ `headers`
|
566
|
+
sig do
|
567
|
+
params(
|
568
|
+
key: T.untyped,
|
569
|
+
partition: Integer,
|
570
|
+
offset: Integer,
|
571
|
+
payload: T.untyped,
|
572
|
+
headers: T.untyped
|
573
|
+
).void
|
574
|
+
end
|
575
|
+
def initialize(key:, partition:, offset:, payload:, headers:); end
|
576
|
+
|
577
|
+
# _@param_ `other`
|
578
|
+
sig { params(other: Phobos::BatchMessage).returns(T::Boolean) }
|
579
|
+
def ==(other); end
|
580
|
+
|
581
|
+
# sord omit - no YARD type given for :key, using untyped
|
582
|
+
sig { returns(T.untyped) }
|
583
|
+
attr_accessor :key
|
584
|
+
|
585
|
+
sig { returns(Integer) }
|
586
|
+
attr_accessor :partition
|
587
|
+
|
588
|
+
sig { returns(Integer) }
|
589
|
+
attr_accessor :offset
|
590
|
+
|
591
|
+
# sord omit - no YARD type given for :payload, using untyped
|
592
|
+
sig { returns(T.untyped) }
|
593
|
+
attr_accessor :payload
|
594
|
+
|
595
|
+
# sord omit - no YARD type given for :headers, using untyped
|
596
|
+
sig { returns(T.untyped) }
|
597
|
+
attr_accessor :headers
|
598
|
+
end
|
599
|
+
|
600
|
+
module Configuration
|
601
|
+
# _@param_ `configuration`
|
602
|
+
sig { params(configuration: T.untyped).void }
|
603
|
+
def configure(configuration); end
|
604
|
+
|
605
|
+
sig { void }
|
606
|
+
def configure_logger; end
|
607
|
+
end
|
608
|
+
|
609
|
+
module Instrumentation
|
610
|
+
NAMESPACE = T.let('phobos', T.untyped)
|
611
|
+
|
612
|
+
# sord omit - no YARD type given for "event", using untyped
|
613
|
+
# sord omit - no YARD return type given, using untyped
|
614
|
+
sig { params(event: T.untyped).returns(T.untyped) }
|
615
|
+
def self.subscribe(event); end
|
616
|
+
|
617
|
+
# sord omit - no YARD type given for "subscriber", using untyped
|
618
|
+
# sord omit - no YARD return type given, using untyped
|
619
|
+
sig { params(subscriber: T.untyped).returns(T.untyped) }
|
620
|
+
def self.unsubscribe(subscriber); end
|
621
|
+
|
622
|
+
# sord omit - no YARD type given for "event", using untyped
|
623
|
+
# sord omit - no YARD type given for "extra", using untyped
|
624
|
+
# sord omit - no YARD return type given, using untyped
|
625
|
+
sig { params(event: T.untyped, extra: T.untyped).returns(T.untyped) }
|
626
|
+
def instrument(event, extra = {}); end
|
627
|
+
end
|
628
|
+
|
629
|
+
module Actions
|
630
|
+
class ProcessBatch
|
631
|
+
include Phobos::Instrumentation
|
632
|
+
include Phobos::Log
|
633
|
+
|
634
|
+
# sord omit - no YARD type given for "listener:", using untyped
|
635
|
+
# sord omit - no YARD type given for "batch:", using untyped
|
636
|
+
# sord omit - no YARD type given for "listener_metadata:", using untyped
|
637
|
+
sig { params(listener: T.untyped, batch: T.untyped, listener_metadata: T.untyped).void }
|
638
|
+
def initialize(listener:, batch:, listener_metadata:); end
|
639
|
+
|
640
|
+
# sord omit - no YARD return type given, using untyped
|
641
|
+
sig { returns(T.untyped) }
|
642
|
+
def execute; end
|
643
|
+
|
644
|
+
# sord omit - no YARD type given for "msg", using untyped
|
645
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
646
|
+
# sord omit - no YARD return type given, using untyped
|
647
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
648
|
+
def log_info(msg, metadata = {}); end
|
649
|
+
|
650
|
+
# sord omit - no YARD type given for "msg", using untyped
|
651
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
652
|
+
# sord omit - no YARD return type given, using untyped
|
653
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
654
|
+
def log_debug(msg, metadata = {}); end
|
655
|
+
|
656
|
+
# sord omit - no YARD type given for "msg", using untyped
|
657
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
658
|
+
# sord omit - no YARD return type given, using untyped
|
659
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
660
|
+
def log_error(msg, metadata); end
|
661
|
+
|
662
|
+
# sord omit - no YARD type given for "msg", using untyped
|
663
|
+
# sord omit - no YARD type given for "metadata", using untyped
|
664
|
+
# sord omit - no YARD return type given, using untyped
|
665
|
+
sig { params(msg: T.untyped, metadata: T.untyped).returns(T.untyped) }
|
666
|
+
def log_warn(msg, metadata = {}); end
|
667
|
+
|
668
|
+
# sord omit - no YARD type given for "event", using untyped
|
669
|
+
# sord omit - no YARD type given for "extra", using untyped
|
670
|
+
# sord omit - no YARD return type given, using untyped
|
671
|
+
sig { params(event: T.untyped, extra: T.untyped).returns(T.untyped) }
|
672
|
+
def instrument(event, extra = {}); end
|
673
|
+
|
674
|
+
# sord omit - no YARD type given for :metadata, using untyped
|
675
|
+
# Returns the value of attribute metadata.
|
676
|
+
sig { returns(T.untyped) }
|
677
|
+
attr_reader :metadata
|
678
|
+
end
|
679
|
+
|
680
|
+
class ProcessMessage
|
681
|
+
include Phobos::Processor
|
682
|
+
|
683
|
+
# sord omit - no YARD type given for "listener:", using untyped
|
684
|
+
# sord omit - no YARD type given for "message:", using untyped
|
685
|
+
# sord omit - no YARD type given for "listener_metadata:", using untyped
|
686
|
+
sig { params(listener: T.untyped, message: T.untyped, listener_metadata: T.untyped).void }
|
687
|
+
def initialize(listener:, message:, listener_metadata:); end
|
688
|
+
|
689
|
+
# sord omit - no YARD return type given, using untyped
|
690
|
+
sig { returns(T.untyped) }
|
691
|
+
def execute; end
|
692
|
+
|
693
|
+
# sord omit - no YARD type given for "interval", using untyped
|
694
|
+
# sord omit - no YARD return type given, using untyped
|
695
|
+
sig { params(interval: T.untyped).returns(T.untyped) }
|
696
|
+
def snooze(interval); end
|
697
|
+
|
698
|
+
# sord omit - no YARD type given for "event", using untyped
|
699
|
+
# sord omit - no YARD type given for "extra", using untyped
|
700
|
+
# sord omit - no YARD return type given, using untyped
|
701
|
+
sig { params(event: T.untyped, extra: T.untyped).returns(T.untyped) }
|
702
|
+
def instrument(event, extra = {}); end
|
703
|
+
|
704
|
+
# sord omit - no YARD type given for :metadata, using untyped
|
705
|
+
# Returns the value of attribute metadata.
|
706
|
+
sig { returns(T.untyped) }
|
707
|
+
attr_reader :metadata
|
708
|
+
end
|
709
|
+
|
710
|
+
class ProcessBatchInline
|
711
|
+
include Phobos::Processor
|
712
|
+
|
713
|
+
# sord omit - no YARD type given for "listener:", using untyped
|
714
|
+
# sord omit - no YARD type given for "batch:", using untyped
|
715
|
+
# sord omit - no YARD type given for "metadata:", using untyped
|
716
|
+
sig { params(listener: T.untyped, batch: T.untyped, metadata: T.untyped).void }
|
717
|
+
def initialize(listener:, batch:, metadata:); end
|
718
|
+
|
719
|
+
# sord omit - no YARD return type given, using untyped
|
720
|
+
sig { returns(T.untyped) }
|
721
|
+
def execute; end
|
722
|
+
|
723
|
+
# sord omit - no YARD type given for "interval", using untyped
|
724
|
+
# sord omit - no YARD return type given, using untyped
|
725
|
+
sig { params(interval: T.untyped).returns(T.untyped) }
|
726
|
+
def snooze(interval); end
|
727
|
+
|
728
|
+
# sord omit - no YARD type given for "event", using untyped
|
729
|
+
# sord omit - no YARD type given for "extra", using untyped
|
730
|
+
# sord omit - no YARD return type given, using untyped
|
731
|
+
sig { params(event: T.untyped, extra: T.untyped).returns(T.untyped) }
|
732
|
+
def instrument(event, extra = {}); end
|
733
|
+
|
734
|
+
# sord omit - no YARD type given for :metadata, using untyped
|
735
|
+
# Returns the value of attribute metadata.
|
736
|
+
sig { returns(T.untyped) }
|
737
|
+
attr_reader :metadata
|
738
|
+
end
|
739
|
+
end
|
740
|
+
end
|