sanger_warren 0.2.0.rc1 → 0.2.0.rc2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6f14e9809f8c71405a3696920321ebbf7477c7f0ecf05421a3ffd85f4fbccfc
4
- data.tar.gz: 5e13bbba217f9b09ad08433178e03f822a6f97e207c80e532a5c8b15c8d36b7b
3
+ metadata.gz: ca7edfe15b95424b868ca931fab20eb671e100fd75d43f4c9c8b03a72fcda71f
4
+ data.tar.gz: 294bf90ca85b4e4912368a152865df9f78e48509dd6feb7a314e56a0c76b8571
5
5
  SHA512:
6
- metadata.gz: 0e2966ea368981ab85de2fc6ed22e349af14f2178862ee0025c79699a494e1d857d96eb23ab1c5fe5a68a24c9f6db68254c488add1d181b9391dc6e17156ca32
7
- data.tar.gz: 8e882eba3c9a5e450447c73784bbed94655bf599c086521c0298a3f9a45433fca703ac52660644b262d837b94f0e793f3393e461dc62d96e76b99cffb1c64a6b
6
+ metadata.gz: f14cdf9e700764fc3b6fa403230c59b6af32b43da4484171677f313cd59e4ae95259c3dcb5ef9604492e4a6039ba7adeaae70171896c206913cb499be3bacf90
7
+ data.tar.gz: bfe863ec509ebe512880aeb762153c823fb0bfa1b0a5b60ad2dc70f898c9549399ca5a53b71fb4a6e284a408b47cef3e188a50cbff9da667bf3055b50e362712
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sanger_warren (0.2.0.rc1)
4
+ sanger_warren (0.2.0.rc2)
5
5
  bunny (~> 2.17.0)
6
6
  connection_pool (~> 2.2.0)
7
7
  multi_json (~> 1.0)
@@ -102,6 +102,7 @@ module Warren
102
102
 
103
103
  def ask_direct_binding
104
104
  exchange = ask_exchange
105
+ routing_key_tip
105
106
  routing_key = @shell.ask 'Specify a routing_key: '
106
107
  add_binding('direct', exchange, { routing_key: routing_key })
107
108
  end
@@ -119,6 +120,7 @@ module Warren
119
120
 
120
121
  def ask_topic_binding
121
122
  exchange = ask_exchange
123
+ routing_key_tip
122
124
  loop do
123
125
  routing_key = @shell.ask 'Specify a routing_key [Leave blank to stop adding]: '
124
126
  break if routing_key == ''
@@ -133,6 +135,17 @@ module Warren
133
135
  'options' => options
134
136
  }
135
137
  end
138
+
139
+ def routing_key_tip
140
+ # Suggested cop style of %<routing_key_prefix>s but prefer suggesting the simpler option as it
141
+ # would be all to easy to miss out the 's', resulting in varying behaviour depending on the following
142
+ # character
143
+ # rubocop:disable Style/FormatStringToken
144
+ @shell.say(
145
+ 'Tip: Use %{routing_key_prefix} in routing keys to reference the routing_key_prefix specified in warren.yml'
146
+ )
147
+ # rubocop:enable Style/FormatStringToken
148
+ end
136
149
  end
137
150
  end
138
151
  end
@@ -17,12 +17,15 @@ module Warren
17
17
  class Channel
18
18
  extend Forwardable
19
19
 
20
+ attr_reader :routing_key_prefix
21
+
20
22
  def_delegators :@bun_channel, :close, :exchange, :queue, :prefetch, :ack, :nack
21
23
 
22
- def initialize(bun_channel, routing_key_template:, exchange: nil)
24
+ def initialize(bun_channel, routing_key_prefix:, exchange: nil)
23
25
  @bun_channel = bun_channel
24
26
  @exchange_name = exchange
25
- @routing_key_template = routing_key_template
27
+ @routing_key_prefix = routing_key_prefix
28
+ @routing_key_template = Handler.routing_key_template(routing_key_prefix)
26
29
  end
27
30
 
28
31
  def <<(message)
@@ -56,7 +59,7 @@ module Warren
56
59
  @server = server
57
60
  @exchange_name = exchange
58
61
  @pool_size = pool_size
59
- @routing_key_template = Handler.routing_key_template(routing_key_prefix)
62
+ @routing_key_prefix = routing_key_prefix
60
63
  end
61
64
 
62
65
  #
@@ -107,7 +110,7 @@ module Warren
107
110
 
108
111
  def new_channel
109
112
  Channel.new(session.create_channel(nil, 1), exchange: @exchange_name,
110
- routing_key_template: @routing_key_template)
113
+ routing_key_prefix: @routing_key_prefix)
111
114
  end
112
115
 
113
116
  private
@@ -64,7 +64,14 @@ module Warren
64
64
  def establish_bindings!
65
65
  @bindings.each do |binding_config|
66
66
  exchange = exchange(binding_config['exchange'])
67
- add_binding(exchange, binding_config['options'])
67
+ transformed_options = merge_routing_key_prefix(binding_config['options'])
68
+ add_binding(exchange, transformed_options)
69
+ end
70
+ end
71
+
72
+ def merge_routing_key_prefix(options)
73
+ options.transform_values do |value|
74
+ format(value, routing_key_prefix: channel.routing_key_prefix)
68
75
  end
69
76
  end
70
77
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Warren
4
4
  # Gem version number. Bump prior to release of new version
5
- VERSION = '0.2.0.rc1'
5
+ VERSION = '0.2.0.rc2'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sanger_warren
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.rc1
4
+ version: 0.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Glover
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-04 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny