racecar 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7132f76843a41197954b9ec72c6cb0c3639803a
4
- data.tar.gz: dca63f90ec004d9116da786060c7469c26001894
3
+ metadata.gz: 227816cc1a2d86b97ae477dba46ef474c18b48e1
4
+ data.tar.gz: 6779b99acc433787743ac1e45963be0931458f11
5
5
  SHA512:
6
- metadata.gz: 1de9ebabb269c7a2e3245e7ed54e71c3348ae9ab71c2c57ed3db51bdde545e8670aa616cebadf14da9124125d5243ccafa60f3955ff08efd2768c7a1b5b9103b
7
- data.tar.gz: e038ce26c4adb7a7e7ce5a5b8a55f3266c4690634890efed34d67dedf72b9ba490d729fd53f7af136fa7ccf078c9f86bfd3bb2ff9eab055e15a1c7faf145c2d4
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
@@ -43,7 +43,7 @@ module Racecar
43
43
  end
44
44
 
45
45
  if config.log_level
46
- Racecar.logger.level = config.log_level
46
+ Racecar.logger.level = Object.const_get("Logger::#{config.log_level.upcase}")
47
47
  end
48
48
 
49
49
  if config.datadog_enabled
@@ -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
- processor.process(message)
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
- processor.process_batch(batch)
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"
@@ -1,3 +1,3 @@
1
1
  module Racecar
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
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
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-11-07 00:00:00.000000000 Z
12
+ date: 2017-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: king_konf