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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -0
- data/lib/freddy/version.rb +1 -1
- data/lib/freddy.rb +3 -0
- data/spec/freddy/freddy_spec.rb +27 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d728d028687af2cb365212bcbdc4bb278b2116ff665f64aa35ee75c057126455
|
4
|
+
data.tar.gz: '019059f31b8da95352ec6b66e47ec73ff762b5b8c82b912d044b6e1820f717b2'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eae3c233c958e0936d1da27dc99bc83274a2e673bc4107e2716617fd23c389a4c27632777ecefebb8a7a17a73246a3ba5c208436143d5a39b7030f446bb9e6b
|
7
|
+
data.tar.gz: 17901b6c33f2a454032b23e8afb195e5f37cc1481f75f77b9f88c759f225dd4b3e1bb5a0547d6c62c0730df8d9757215ec5d2fd3c35a199a71595e07348c3277
|
data/Gemfile.lock
CHANGED
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
|
data/lib/freddy/version.rb
CHANGED
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
|
data/spec/freddy/freddy_spec.rb
CHANGED
@@ -7,7 +7,15 @@ describe Freddy do
|
|
7
7
|
let(:destination2) { random_destination }
|
8
8
|
let(:payload) { { pay: 'load' } }
|
9
9
|
|
10
|
-
|
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.
|
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-
|
11
|
+
date: 2023-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|