freddy 2.7.0 → 2.8.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
  SHA256:
3
- metadata.gz: addf621163f5d1faf987bf6ab91d027a538631303543833e1aea8946d3bc0e0b
4
- data.tar.gz: 22d6eddbd383a2d7b7b46a4e69b2f78b1a0ba6e8a803a1c8b13be7a8be9d3948
3
+ metadata.gz: d728d028687af2cb365212bcbdc4bb278b2116ff665f64aa35ee75c057126455
4
+ data.tar.gz: '019059f31b8da95352ec6b66e47ec73ff762b5b8c82b912d044b6e1820f717b2'
5
5
  SHA512:
6
- metadata.gz: 569d91cfe03265013e808bd1847c023b5e307e0411b12ef8113e54e3c471953f21f7a0ed3603c81513cf4a4d628447347d1d582e808b14cdd7f58ef5c8d5023c
7
- data.tar.gz: bdeb3e75486d8f026e30d1766db834f2d6f7bad2e788f8d74eaaa836e428d02f56101d1e67b8ec5697cbd04ed9b891e6b98933d5c483c17e200b64cf8b877afd
6
+ metadata.gz: 4eae3c233c958e0936d1da27dc99bc83274a2e673bc4107e2716617fd23c389a4c27632777ecefebb8a7a17a73246a3ba5c208436143d5a39b7030f446bb9e6b
7
+ data.tar.gz: 17901b6c33f2a454032b23e8afb195e5f37cc1481f75f77b9f88c759f225dd4b3e1bb5a0547d6c62c0730df8d9757215ec5d2fd3c35a199a71595e07348c3277
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- freddy (2.7.0)
4
+ freddy (2.8.0)
5
5
  bunny (~> 2.11)
6
6
  concurrent-ruby (~> 1.0)
7
7
  oj (~> 3.6)
data/README.md CHANGED
@@ -55,6 +55,11 @@ The message heading specify the `content-encoding` indicating the compression al
55
55
  freddy.deliver(destination, message, compress: 'zlib')
56
56
  ```
57
57
 
58
+ #### Metadata through headers
59
+
60
+ Send a message with arbitrary message metadata included in the message headers
61
+ freddy.deliver(destination, message, headers: {'my-key' => 'my-value'})
62
+
58
63
  ### Request delivery
59
64
 
60
65
  #### Expiring messages
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Freddy
4
- VERSION = '2.7.0'
4
+ VERSION = '2.8.0'
5
5
  end
data/lib/freddy.rb CHANGED
@@ -166,6 +166,8 @@ class Freddy
166
166
  # won't be discarded if timeout it set to 0 (default).
167
167
  # @option options [String] :compress (nil)
168
168
  # - 'zlib' - compresses the payload with zlib
169
+ # @option options [Hash] :headers (nil)
170
+ # Arbitrary headers to add as message metadata
169
171
  # @return [void]
170
172
  #
171
173
  # @example
@@ -176,6 +178,7 @@ class Freddy
176
178
  opts = {}
177
179
  opts[:expiration] = (timeout * 1000).to_i if timeout.positive?
178
180
  opts[:content_encoding] = compression_algorithm if compression_algorithm
181
+ opts[:headers] = options[:headers] if options[:headers]
179
182
 
180
183
  @send_and_forget_producer.produce(destination, payload, opts)
181
184
  end
@@ -7,7 +7,15 @@ describe Freddy do
7
7
  let(:destination2) { random_destination }
8
8
  let(:payload) { { pay: 'load' } }
9
9
 
10
- after { freddy.close }
10
+ before do
11
+ @bunny = Bunny.new(config)
12
+ @bunny.start
13
+ end
14
+
15
+ after do
16
+ @bunny.close
17
+ freddy.close
18
+ end
11
19
 
12
20
  def respond_to(&block)
13
21
  freddy.respond_to(destination, &block)
@@ -72,6 +80,24 @@ describe Freddy do
72
80
  expect(@tapped_message).to eq(payload)
73
81
  end
74
82
  end
83
+
84
+ it 'accepts custom headers' do
85
+ headers = nil
86
+ queue = exclusive_subscribe do |_info, metadata, _payload|
87
+ headers = metadata[:headers]
88
+ end
89
+ freddy.deliver(queue, payload, headers: { 'foo' => 'bar' })
90
+
91
+ wait_for { headers }
92
+ expect(headers).to include({ 'foo' => 'bar' })
93
+ end
94
+ end
95
+
96
+ def exclusive_subscribe(&block)
97
+ channel = @bunny.create_channel
98
+ queue = channel.queue('', exclusive: true)
99
+ queue.subscribe(&block)
100
+ queue.name
75
101
  end
76
102
 
77
103
  context 'when making a synchronized request' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glia TechMovers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-19 00:00:00.000000000 Z
11
+ date: 2023-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler