racecar 0.3.0.beta1 → 0.3.0

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: 21f3ecc4525a97eace384c5702c7f37939920292
4
- data.tar.gz: 6bf40c5f643a9f0eb8fe6a962793a04e020becd4
3
+ metadata.gz: c0651e97f7403aacaf9494cb2cc2833b7b6040a5
4
+ data.tar.gz: d5849ff77aec0112c92d56937cb4ab30d926dc16
5
5
  SHA512:
6
- metadata.gz: 17a690c3206dc413c8795b36d2a8d01afbab74bbcd48a2c0e1d64bb8a662ae2d41516a4446d140967d5266e1bc5755b4e0814f269fc6c6f6dc1892eac7e05ed1
7
- data.tar.gz: c811af7f6f5aa7cdd3953e1e954964ad6903e7740600e9ae16e5b8b2ef27234116b48c60fa6851d9166b157a07f1e44b851c310fd1a784a9717728d8218f43fc
6
+ metadata.gz: 5781c4b863eefed5f336c5cfd5f7832ed8d6c248f5064eb7a1729222676c0ed88663dc7db1ca9f7d1adda5dc470317fdd78ea3c15246ab4d4eb23d6480f57977
7
+ data.tar.gz: bcb8e7d8b5d1aed13c68d7257381d0d710979dde5dbcc34ba9e7649ce53e3e11031deaa410fc9b046f5914690eec41d114ff7ee38a16ee554f96f4259b983524
data/Procfile ADDED
@@ -0,0 +1,2 @@
1
+ batch: bundle exec racecar --require examples/batch_consumer BatchConsumer
2
+ cat: bundle exec racecar --require examples/cat_consumer CatConsumer
data/README.md CHANGED
@@ -13,7 +13,8 @@ Using [ruby-kafka](https://github.com/zendesk/ruby-kafka) directly can be a chal
13
13
  3. [Configuration](#configuration)
14
14
  4. [Testing consumers](#testing-consumers)
15
15
  5. [Deploying consumers](#deploying-consumers)
16
- 6. [Operations](#operations)
16
+ 6. [Logging](#logging)
17
+ 7. [Operations](#operations)
17
18
  3. [Development](#development)
18
19
  4. [Contributing](#contributing)
19
20
  5. [Copyright and license](#copyright-and-license)
@@ -255,6 +256,13 @@ If you've ever used Heroku you'll recognize the format – indeed, deploying to
255
256
  With Foreman, you can easily run these processes locally by executing `foreman run`; in production you'll want to _export_ to another process management format such as Upstart or Runit. [capistrano-foreman](https://github.com/hyperoslo/capistrano-foreman) allows you to do this with Capistrano.
256
257
 
257
258
 
259
+ ### Logging
260
+
261
+ By default, Racecar will log to `STDOUT`. If you're using Rails, your application code will use whatever logger you've configured there.
262
+
263
+ In order to make Racecar log its own operations to a log file, set the `logfile` configuration variable or pass `--log filename.log` to the `racecar` command.
264
+
265
+
258
266
  ### Operations
259
267
 
260
268
  In order to gracefully shut down a Racecar consumer process, send it the `SIGTERM` signal. Most process supervisors such as Runit and Kubernetes send this signal when shutting down a process, so using those systems will make things easier.
data/lib/racecar/cli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "optparse"
2
+ require "logger"
2
3
  require "racecar/rails_config_file_loader"
3
4
 
4
5
  module Racecar
@@ -11,9 +12,13 @@ module Racecar
11
12
  require lib
12
13
  end
13
14
 
15
+ opts.on("-l", "--log LOGFILE", "Log to the specified file") do |logfile|
16
+ Racecar.config.logfile = logfile
17
+ end
18
+
14
19
  opts.on_tail("--version", "Show Racecar version") do
15
20
  require "racecar/version"
16
- puts "Racecar #{Racecar::VERSION}"
21
+ $stderr.puts "Racecar #{Racecar::VERSION}"
17
22
  exit
18
23
  end
19
24
  end
@@ -22,7 +27,7 @@ module Racecar
22
27
 
23
28
  consumer_name = args.first or raise Racecar::Error, "no consumer specified"
24
29
 
25
- puts "=> Starting Racecar consumer #{consumer_name}..."
30
+ $stderr.puts "=> Starting Racecar consumer #{consumer_name}..."
26
31
 
27
32
  RailsConfigFileLoader.load!
28
33
 
@@ -34,14 +39,19 @@ module Racecar
34
39
 
35
40
  Racecar.config.validate!
36
41
 
37
- puts "=> Wrooooom!"
38
- puts "=> Ctrl-C to shutdown consumer"
42
+ if Racecar.config.logfile
43
+ $stderr.puts "=> Logging to #{Racecar.config.logfile}"
44
+ Racecar.logger = Logger.new(Racecar.config.logfile)
45
+ end
46
+
47
+ $stderr.puts "=> Wrooooom!"
48
+ $stderr.puts "=> Ctrl-C to shutdown consumer"
39
49
 
40
50
  processor = consumer_class.new
41
51
 
42
52
  Racecar.run(processor)
43
53
 
44
- puts "=> Shut down"
54
+ $stderr.puts "=> Shut down"
45
55
  end
46
56
  end
47
57
  end
@@ -21,7 +21,7 @@ module Racecar
21
21
  max_wait_time
22
22
 
23
23
  error_handler
24
- log_to_stdout
24
+ logfile
25
25
 
26
26
  ssl_ca_cert
27
27
  ssl_ca_cert_file_path
@@ -43,7 +43,6 @@ module Racecar
43
43
  DEFAULT_CONFIG = {
44
44
  brokers: ["localhost:9092"],
45
45
  client_id: "racecar",
46
- group_id_prefix: nil,
47
46
 
48
47
  subscriptions: [],
49
48
 
@@ -72,9 +71,6 @@ module Racecar
72
71
 
73
72
  # Default is to do nothing on exceptions.
74
73
  error_handler: proc {},
75
-
76
- # Default is to only log to the logger.
77
- log_to_stdout: false,
78
74
  }
79
75
 
80
76
  attr_accessor(*ALLOWED_KEYS)
data/lib/racecar/ctl.rb CHANGED
@@ -60,7 +60,7 @@ module Racecar
60
60
 
61
61
  kafka.deliver_message(message.value, key: message.key, topic: message.topic)
62
62
 
63
- puts "=> Delivered message to Kafka cluster"
63
+ $stderr.puts "=> Delivered message to Kafka cluster"
64
64
  end
65
65
  end
66
66
  end
@@ -6,21 +6,20 @@ module Racecar
6
6
  begin
7
7
  require "rails"
8
8
 
9
- puts "=> Detected Rails, booting application..."
9
+ $stderr.puts "=> Detected Rails, booting application..."
10
10
 
11
11
  require "./config/environment"
12
12
 
13
13
  Racecar.config.load_file(config_file, Rails.env)
14
14
 
15
- if Racecar.config.log_to_stdout
16
- # Write to STDOUT as well as to the log file.
15
+ # In development, write Rails logs to STDOUT. This mirrors what e.g.
16
+ # Unicorn does.
17
+ if Rails.env.development?
17
18
  console = ActiveSupport::Logger.new($stdout)
18
19
  console.formatter = Rails.logger.formatter
19
20
  console.level = Rails.logger.level
20
21
  Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
21
22
  end
22
-
23
- Racecar.logger = Rails.logger
24
23
  rescue LoadError
25
24
  # Not a Rails application.
26
25
  end
@@ -1,3 +1,3 @@
1
1
  module Racecar
2
- VERSION = "0.3.0.beta1"
2
+ VERSION = "0.3.0"
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.0.beta1
4
+ version: 0.3.0
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-08-03 00:00:00.000000000 Z
12
+ date: 2017-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-kafka
@@ -81,6 +81,7 @@ files:
81
81
  - ".rspec"
82
82
  - Gemfile
83
83
  - LICENSE.txt
84
+ - Procfile
84
85
  - README.md
85
86
  - Rakefile
86
87
  - bin/console
@@ -118,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  requirements:
121
- - - ">"
122
+ - - ">="
122
123
  - !ruby/object:Gem::Version
123
- version: 1.3.1
124
+ version: '0'
124
125
  requirements: []
125
126
  rubyforge_project:
126
127
  rubygems_version: 2.4.5.1