railway-ipc 2.2.0 → 2.2.1

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
  SHA256:
3
- metadata.gz: ade6188ad53835d058964953332583db7cf146f2b02b58c4a25cddb42e7f89cf
4
- data.tar.gz: 4672c6b08a293c1988f42c944063cc9ba67d6656531b8c3a3fd9b00ab908219e
3
+ metadata.gz: 8153f89992dd3713ca4b6e8792a69d91e80738ae69d26bd3325616c30d854bf2
4
+ data.tar.gz: d6680bb1330b885172730f7e9110a255896931d2e627cb50c2b0384cd4a423b2
5
5
  SHA512:
6
- metadata.gz: a76acd180339079bc95bd042e6a6c2512edd05d485ca2763e8211278f85adf0677156f1e8d305ce5cc4186c9304ed85e7c8343b0a32b79560225e1261e7801a9
7
- data.tar.gz: ceab6497161f8c640cbb2da715b9380729b1e8dbb40843d11fd879a32214e7f39f5aa130d811eeff66c0f0b59eea743e6cb97aa8fb89bcb2fa62aa06ceffb65f
6
+ metadata.gz: 404ec939662fbc9f4f8e571b95f3d86222c2d8039afd46346ed10b4319b2f5d8a307d4a0047cc75e041b17393031d0a0551088d2f291d4bf70ecd28baf98b449
7
+ data.tar.gz: efb5cb9aa4635e7d4a07344a61de6bd1f61d39fecbd8445e7baa2d375413603b7e9398cf391feac8b04a7a7c6fc46f5e9cd56791188ed6fb3e233a856a8e1caa
data/.gitignore CHANGED
@@ -8,6 +8,9 @@
8
8
  /tmp/
9
9
  Gemfile.lock
10
10
 
11
+ # built gems
12
+ railway-ipc-*.gem
13
+
11
14
  # rspec failure tracking
12
15
  .rspec_status
13
16
 
data/README.md CHANGED
@@ -52,6 +52,26 @@ Then, run your consumers
52
52
  bundle exec rake railway_ipc:consumers:start CONSUMERS=YourConsumer,YourOtherConsumer
53
53
  ```
54
54
 
55
+ You may also configure your consumers more granularly using:
56
+
57
+ `./config/sneaker_worker_groups.yml`
58
+ ```yaml
59
+ HighPriority:
60
+ classes: YourConsumer,YourOtherConsumer
61
+ workers: 5
62
+ LowPriority:
63
+ classes: YourThirdConsumer
64
+ workers: 1
65
+ ```
66
+
67
+ ```bash
68
+ bundle exec rake railway_ipc:consumers:spawn
69
+ ```
70
+
71
+ By default, `spawn` will map to `./config/sneaker_worker_groups.yml` but you can override it by using `WORKER_GROUP_CONFIG`.
72
+
73
+ See the [Sneaker Documentation](https://github.com/jondot/sneakers/wiki/Handling-different-workloads) for more information.
74
+
55
75
  # Request/Response
56
76
 
57
77
  Define your server, client and responder. Docs coming soon.
@@ -5,7 +5,6 @@ require 'sneakers'
5
5
  require 'sneakers/spawner'
6
6
  require 'bunny'
7
7
  require 'active_record'
8
- require 'railway_ipc/version'
9
8
  require 'railway_ipc/logger'
10
9
  require 'railway_ipc/unhandled_message_error'
11
10
  require 'railway_ipc/response'
@@ -34,12 +33,12 @@ module RailwayIpc
34
33
  Sneakers::Spawner.spawn
35
34
  end
36
35
 
37
- def self.configure(log_device=STDOUT, level=::Logger::INFO, log_formatter=nil)
36
+ def self.configure(log_device=$stdout, level=::Logger::INFO, log_formatter=nil)
38
37
  @logger = RailwayIpc::Logger.new(log_device, level, log_formatter)
39
38
  end
40
39
 
41
40
  def self.logger
42
- @logger || RailwayIpc::Logger.new(STDOUT)
41
+ @logger || RailwayIpc::Logger.new($stdout)
43
42
  end
44
43
 
45
44
  def self.bunny_connection
@@ -5,6 +5,8 @@ module RailwayIpc
5
5
  include Sneakers::Worker
6
6
 
7
7
  def self.inherited(base)
8
+ super
9
+
8
10
  base.instance_eval do
9
11
  def handlers
10
12
  @handlers ||= RailwayIpc::HandlerStore.new
@@ -13,6 +15,14 @@ module RailwayIpc
13
15
  end
14
16
 
15
17
  def self.listen_to(queue:, exchange:, options: {})
18
+ unless options.empty?
19
+ RailwayIpc.logger.info(
20
+ "Overriding configuration for #{queue} with new options",
21
+ feature: 'railway_ipc_consumer',
22
+ options: options
23
+ )
24
+ end
25
+
16
26
  from_queue queue, {
17
27
  exchange: exchange,
18
28
  durable: true,
@@ -21,7 +21,7 @@ module RailwayIpc
21
21
  # logger = RailwayIpc::Logger.new(STDOUT, Logger::INFO, OjFormatter)
22
22
  #
23
23
  class Logger
24
- def initialize(device=STDOUT, level=::Logger::INFO, formatter=nil)
24
+ def initialize(device=$stdout, level=::Logger::INFO, formatter=nil)
25
25
  @logger = ::Logger.new(device)
26
26
  @logger.level = level
27
27
  @logger.formatter = formatter if formatter
@@ -32,7 +32,7 @@ module RailwayIpc
32
32
  data.merge!(feature: 'railway_ipc') unless data.key?(:feature)
33
33
  return logger.send(level, data.merge(message: message)) unless block
34
34
 
35
- data = message.merge(data) if message&.is_a?(Hash)
35
+ data = message.merge(data) if message.is_a?(Hash)
36
36
  data.merge!(message: block.call)
37
37
 
38
38
  # This is for compatability w/ Ruby's Logger. Ruby's Logger class
@@ -41,7 +41,7 @@ module RailwayIpc
41
41
  # is assumed to be the `progname`.
42
42
  #
43
43
  # https://github.com/ruby/logger/blob/master/lib/logger.rb#L471
44
- data.merge!(progname: message) if message&.is_a?(String)
44
+ data.merge!(progname: message) if message.is_a?(String)
45
45
  logger.send(level, data)
46
46
  end
47
47
  end
@@ -16,7 +16,7 @@ module RailwayIpc
16
16
  :port,
17
17
  :user
18
18
 
19
- def initialize(amqp_url: ENV['RAILWAY_RABBITMQ_CONNECTION_URL'], exchange_name:, queue_name: '', options: {})
19
+ def initialize(exchange_name:, amqp_url: ENV['RAILWAY_RABBITMQ_CONNECTION_URL'], queue_name: '', options: {})
20
20
  @queue_name = queue_name
21
21
  @exchange_name = exchange_name
22
22
  settings = AMQ::Settings.parse_amqp_url(amqp_url)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailwayIpc
4
- VERSION = '2.2.0'
4
+ VERSION = '2.2.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railway-ipc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2020-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler