racecar 0.3.4 → 0.3.5
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/CHANGELOG.md +7 -0
- data/lib/racecar.rb +18 -1
- data/lib/racecar/cli.rb +1 -1
- data/lib/racecar/runner.rb +33 -3
- data/lib/racecar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 227816cc1a2d86b97ae477dba46ef474c18b48e1
|
4
|
+
data.tar.gz: 6779b99acc433787743ac1e45963be0931458f11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84f6a4fa70d0e680d17d4a6418c752353443263444528fd0d37a85e89b4005637627243b0150486a85b0439b8e1dd3b748e8f2a6d9296ee3c041f40de3b3cc03
|
7
|
+
data.tar.gz: 8d6262f0499bb2aa84d8beada1710fd32a97fad17aa8853f07cc90d38d739c1f65a5f40a9e4c0a409c9ca2e3f7a60eade093a0ed9d76569716e37d45a72b14d5
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## racecar v0.3.5
|
6
|
+
|
7
|
+
* Instrument using ActiveSupport::Notifications (#43).
|
8
|
+
* Add support for SASL.
|
9
|
+
|
10
|
+
## racecar v0.3.4
|
11
|
+
|
5
12
|
* Use KingKonf for defining configuration variables.
|
6
13
|
* Allow setting configuration variables through the CLI.
|
7
14
|
* Make all configuration variables available over the ENV.
|
data/lib/racecar.rb
CHANGED
@@ -5,6 +5,13 @@ require "racecar/runner"
|
|
5
5
|
require "racecar/config"
|
6
6
|
|
7
7
|
module Racecar
|
8
|
+
# Ignores all instrumentation events.
|
9
|
+
class NullInstrumenter
|
10
|
+
def self.instrument(*)
|
11
|
+
yield if block_given?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
8
15
|
class Error < StandardError
|
9
16
|
end
|
10
17
|
|
@@ -27,7 +34,17 @@ module Racecar
|
|
27
34
|
@logger = logger
|
28
35
|
end
|
29
36
|
|
37
|
+
def self.instrumenter
|
38
|
+
require "active_support/notifications"
|
39
|
+
|
40
|
+
ActiveSupport::Notifications
|
41
|
+
rescue LoadError
|
42
|
+
logger.warn "ActiveSupport::Notifications not available, instrumentation is disabled"
|
43
|
+
|
44
|
+
NullInstrumenter
|
45
|
+
end
|
46
|
+
|
30
47
|
def self.run(processor)
|
31
|
-
Runner.new(processor, config: config, logger: logger).run
|
48
|
+
Runner.new(processor, config: config, logger: logger, instrumenter: instrumenter).run
|
32
49
|
end
|
33
50
|
end
|
data/lib/racecar/cli.rb
CHANGED
data/lib/racecar/runner.rb
CHANGED
@@ -4,8 +4,9 @@ module Racecar
|
|
4
4
|
class Runner
|
5
5
|
attr_reader :processor, :config, :logger, :consumer
|
6
6
|
|
7
|
-
def initialize(processor, config:, logger:)
|
7
|
+
def initialize(processor, config:, logger:, instrumenter: NullInstrumenter)
|
8
8
|
@processor, @config, @logger = processor, config, logger
|
9
|
+
@instrumenter = instrumenter
|
9
10
|
end
|
10
11
|
|
11
12
|
def stop
|
@@ -23,6 +24,8 @@ module Racecar
|
|
23
24
|
ssl_ca_cert: config.ssl_ca_cert,
|
24
25
|
ssl_client_cert: config.ssl_client_cert,
|
25
26
|
ssl_client_cert_key: config.ssl_client_cert_key,
|
27
|
+
sasl_plain_username: config.sasl_plain_username,
|
28
|
+
sasl_plain_password: config.sasl_plain_password,
|
26
29
|
)
|
27
30
|
|
28
31
|
@consumer = kafka.consumer(
|
@@ -52,11 +55,38 @@ module Racecar
|
|
52
55
|
begin
|
53
56
|
if processor.respond_to?(:process)
|
54
57
|
consumer.each_message(max_wait_time: config.max_wait_time) do |message|
|
55
|
-
|
58
|
+
payload = {
|
59
|
+
consumer_class: processor.class.to_s,
|
60
|
+
topic: message.topic,
|
61
|
+
partition: message.partition,
|
62
|
+
offset: message.offset,
|
63
|
+
}
|
64
|
+
|
65
|
+
# Allow subscribers to receive a notification *before* we process the
|
66
|
+
# message.
|
67
|
+
@instrumenter.instrument("start_process_message.racecar", payload)
|
68
|
+
|
69
|
+
@instrumenter.instrument("process_message.racecar", payload) do
|
70
|
+
processor.process(message)
|
71
|
+
end
|
56
72
|
end
|
57
73
|
elsif processor.respond_to?(:process_batch)
|
58
74
|
consumer.each_batch(max_wait_time: config.max_wait_time) do |batch|
|
59
|
-
|
75
|
+
payload = {
|
76
|
+
consumer_class: processor.class.to_s,
|
77
|
+
topic: batch.topic,
|
78
|
+
partition: batch.partition,
|
79
|
+
first_offset: batch.first_offset,
|
80
|
+
message_count: batch.messages.count,
|
81
|
+
}
|
82
|
+
|
83
|
+
# Allow subscribers to receive a notification *before* we process the
|
84
|
+
# message.
|
85
|
+
@instrumenter.instrument("start_process_batch.racecar", payload)
|
86
|
+
|
87
|
+
@instrumenter.instrument("process_batch.racecar", payload) do
|
88
|
+
processor.process_batch(batch)
|
89
|
+
end
|
60
90
|
end
|
61
91
|
else
|
62
92
|
raise NotImplementedError, "Consumer class must implement process or process_batch method"
|
data/lib/racecar/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: racecar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schierbeck
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: king_konf
|