rabbit_messaging 1.6.3 → 1.7.0
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +19 -8
- data/lib/rabbit/publishing/job.rb +1 -1
- data/lib/rabbit/publishing/message.rb +18 -9
- data/lib/rabbit/version.rb +1 -1
- data/lib/rabbit.rb +32 -4
- 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: efe11548384ee579affeb4b5f73d1bb11381c72537817f91281c535c277ea1ac
|
4
|
+
data.tar.gz: cd1e1d4afae41948c557df57d9089b2e091b21aaab45d9276329bdfe54b890d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28dd5ee469eb76e1b072ce812ef8b2e2f184aa8ced27e4b824071c6768c83a328ff472333c17f3221e19b5c7cdf1c29af37a6f0a2042f11011ac4c056e014958
|
7
|
+
data.tar.gz: 5cd054a92e8942c78f18fdb6c94a36a229e4046669c89c9b26cec17accdc1075dafcd35be1cd741c2849d8750bdec11d067bad4db5004ca73e66bda9d16b55c2
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [1.7.0] - 2025-08-19
|
5
|
+
### Added
|
6
|
+
- Ability to specify a custom job class for publishing via `publishing_job_class_callable` config.
|
7
|
+
- Ability to specify a default queue for publishing jobs via `default_publishing_job_queue` config.
|
8
|
+
- Ability to specify a custom queue per publish call via `custom_queue_name` argument.
|
9
|
+
|
4
10
|
## [1.5.0] - 2025-05-19
|
5
11
|
### Added
|
6
12
|
- Added ability to split log message into parts
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -97,6 +97,14 @@ require "rabbit_messaging"
|
|
97
97
|
}
|
98
98
|
```
|
99
99
|
|
100
|
+
- `publishing_job_class_callable` (`Proc`)
|
101
|
+
|
102
|
+
Custom job class (e.g. ActiveJob or Sidekiq::Job) to work with published messages.
|
103
|
+
|
104
|
+
- `default_publishing_job_queue` (`String` or `Symbol`)
|
105
|
+
|
106
|
+
The name of the queue that will be used by default for publishing jobs. `default` by default.
|
107
|
+
|
100
108
|
- `before_receiving_hooks, after_receiving_hooks` (`Array of Procs`)
|
101
109
|
|
102
110
|
Before and after hooks with message processing in the middle. Where `before_receiving_hooks` and `after_receiving_hooks` are empty arrays by default.
|
@@ -139,7 +147,7 @@ require "rabbit_messaging"
|
|
139
147
|
- `connection_reset_max_retries` (`Integer`)
|
140
148
|
|
141
149
|
Maximum number of reconnection attempts after a connection loss. Default: 10.
|
142
|
-
|
150
|
+
|
143
151
|
```ruby
|
144
152
|
config.connection_reset_max_retries = 20
|
145
153
|
```
|
@@ -165,13 +173,16 @@ require "rabbit_messaging"
|
|
165
173
|
|
166
174
|
```ruby
|
167
175
|
Rabbit.publish(
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
176
|
+
{
|
177
|
+
routing_key: :support,
|
178
|
+
event: :ping,
|
179
|
+
data: { foo: :bar }, # default is {}
|
180
|
+
exchange_name: 'fanout', # default is fine too
|
181
|
+
confirm_select: true, # setting this to false grants you great speed up and absolutelly no guarantees
|
182
|
+
headers: { "foo" => "bar" }, # custom arguments for routing, default is {}
|
183
|
+
message_id: "asdadsadsad", # A unique identifier such as a UUID that your application can use to identify the message.
|
184
|
+
},
|
185
|
+
custom_queue_name: :my_custom_queue, # The name of the queue for publishing jobs. Overrides the default queue.
|
175
186
|
)
|
176
187
|
```
|
177
188
|
|
@@ -9,15 +9,24 @@ module Rabbit::Publishing
|
|
9
9
|
alias_method :confirm_select?, :confirm_select
|
10
10
|
alias_method :realtime?, :realtime
|
11
11
|
|
12
|
-
def initialize(
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
def initialize(
|
13
|
+
routing_key: nil,
|
14
|
+
event: nil,
|
15
|
+
data: {},
|
16
|
+
exchange_name: [],
|
17
|
+
confirm_select: true,
|
18
|
+
realtime: false,
|
19
|
+
headers: {},
|
20
|
+
message_id: nil
|
21
|
+
)
|
22
|
+
self.routing_key = routing_key
|
23
|
+
self.event = event&.to_s
|
24
|
+
self.data = data
|
25
|
+
self.exchange_name = Array(exchange_name)
|
26
|
+
self.confirm_select = confirm_select
|
27
|
+
self.realtime = realtime
|
28
|
+
self.headers = headers
|
29
|
+
self.message_id = message_id
|
21
30
|
end
|
22
31
|
|
23
32
|
def to_hash
|
data/lib/rabbit/version.rb
CHANGED
data/lib/rabbit.rb
CHANGED
@@ -18,6 +18,8 @@ module Rabbit
|
|
18
18
|
:hooks,
|
19
19
|
:queue_name_conversion,
|
20
20
|
:receiving_job_class_callable,
|
21
|
+
:publishing_job_class_callable,
|
22
|
+
:default_publishing_job_queue,
|
21
23
|
:handler_resolver_callable,
|
22
24
|
:exception_notifier,
|
23
25
|
:before_receiving_hooks,
|
@@ -41,6 +43,8 @@ module Rabbit
|
|
41
43
|
environment: :production,
|
42
44
|
queue_name_conversion: nil,
|
43
45
|
receiving_job_class_callable: nil,
|
46
|
+
publishing_job_class_callable: nil,
|
47
|
+
default_publishing_job_queue: :default,
|
44
48
|
handler_resolver_callable: nil,
|
45
49
|
exception_notifier: nil,
|
46
50
|
before_receiving_hooks: [],
|
@@ -63,6 +67,8 @@ module Rabbit
|
|
63
67
|
self.environment = environment.to_sym
|
64
68
|
self.queue_name_conversion = queue_name_conversion
|
65
69
|
self.receiving_job_class_callable = receiving_job_class_callable
|
70
|
+
self.publishing_job_class_callable = publishing_job_class_callable
|
71
|
+
self.default_publishing_job_queue = default_publishing_job_queue
|
66
72
|
self.handler_resolver_callable = handler_resolver_callable
|
67
73
|
self.exception_notifier = exception_notifier
|
68
74
|
self.before_receiving_hooks = before_receiving_hooks
|
@@ -163,13 +169,35 @@ module Rabbit
|
|
163
169
|
config.validate!
|
164
170
|
end
|
165
171
|
|
166
|
-
def publish(
|
167
|
-
|
172
|
+
def publish(
|
173
|
+
routing_key: nil,
|
174
|
+
event: nil,
|
175
|
+
data: {},
|
176
|
+
exchange_name: [],
|
177
|
+
confirm_select: true,
|
178
|
+
realtime: false,
|
179
|
+
headers: {},
|
180
|
+
message_id: nil,
|
181
|
+
custom_queue_name: nil
|
182
|
+
)
|
183
|
+
message = Publishing::Message.new(
|
184
|
+
routing_key: routing_key,
|
185
|
+
event: event,
|
186
|
+
data: data,
|
187
|
+
exchange_name: exchange_name,
|
188
|
+
confirm_select: confirm_select,
|
189
|
+
realtime: realtime,
|
190
|
+
headers: headers,
|
191
|
+
message_id: message_id,
|
192
|
+
)
|
193
|
+
job_class = config.publishing_job_class_callable
|
194
|
+
publish_job_callable = job_class.is_a?(Proc) ? job_class.call : (job_class || Publishing::Job)
|
195
|
+
queue_name = custom_queue_name || default_queue_name
|
168
196
|
|
169
197
|
if message.realtime?
|
170
198
|
Publishing.publish(message)
|
171
199
|
else
|
172
|
-
|
200
|
+
publish_job_callable.set(queue: queue_name).perform_later(message.to_hash)
|
173
201
|
end
|
174
202
|
end
|
175
203
|
|
@@ -179,6 +207,6 @@ module Rabbit
|
|
179
207
|
end
|
180
208
|
|
181
209
|
def default_queue_name(ignore_conversion: false)
|
182
|
-
queue_name(
|
210
|
+
queue_name(config.default_publishing_job_queue, ignore_conversion: ignore_conversion)
|
183
211
|
end
|
184
212
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Umbrellio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|