rabbit_messaging 1.6.2 → 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 +37 -5
- metadata +6 -3
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
@@ -16,9 +16,10 @@ module Rabbit
|
|
16
16
|
:project_id,
|
17
17
|
:queue_suffix,
|
18
18
|
:hooks,
|
19
|
-
:environment,
|
20
19
|
:queue_name_conversion,
|
21
20
|
:receiving_job_class_callable,
|
21
|
+
:publishing_job_class_callable,
|
22
|
+
:default_publishing_job_queue,
|
22
23
|
:handler_resolver_callable,
|
23
24
|
:exception_notifier,
|
24
25
|
:before_receiving_hooks,
|
@@ -31,6 +32,7 @@ module Rabbit
|
|
31
32
|
:connection_reset_exceptions,
|
32
33
|
:logger_message_size_limit
|
33
34
|
|
35
|
+
attr_reader :environment
|
34
36
|
attr_writer :receive_logger, :publish_logger, :malformed_logger
|
35
37
|
|
36
38
|
def initialize( # rubocop:disable Metrics/MethodLength
|
@@ -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
|
@@ -114,6 +120,10 @@ module Rabbit
|
|
114
120
|
@malformed_logger || default_malformed_logger
|
115
121
|
end
|
116
122
|
|
123
|
+
def environment=(value)
|
124
|
+
@environment = value.to_sym
|
125
|
+
end
|
126
|
+
|
117
127
|
private
|
118
128
|
|
119
129
|
def default_receive_logger
|
@@ -159,13 +169,35 @@ module Rabbit
|
|
159
169
|
config.validate!
|
160
170
|
end
|
161
171
|
|
162
|
-
def publish(
|
163
|
-
|
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
|
164
196
|
|
165
197
|
if message.realtime?
|
166
198
|
Publishing.publish(message)
|
167
199
|
else
|
168
|
-
|
200
|
+
publish_job_callable.set(queue: queue_name).perform_later(message.to_hash)
|
169
201
|
end
|
170
202
|
end
|
171
203
|
|
@@ -175,6 +207,6 @@ module Rabbit
|
|
175
207
|
end
|
176
208
|
|
177
209
|
def default_queue_name(ignore_conversion: false)
|
178
|
-
queue_name(
|
210
|
+
queue_name(config.default_publishing_job_queue, ignore_conversion: ignore_conversion)
|
179
211
|
end
|
180
212
|
end
|
metadata
CHANGED
@@ -1,13 +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
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date:
|
11
|
+
date: 2025-09-10 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: bunny
|
@@ -83,6 +84,7 @@ files:
|
|
83
84
|
homepage: https://github.com/umbrellio/rabbit_messaging
|
84
85
|
licenses: []
|
85
86
|
metadata: {}
|
87
|
+
post_install_message:
|
86
88
|
rdoc_options: []
|
87
89
|
require_paths:
|
88
90
|
- lib
|
@@ -97,7 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
99
|
- !ruby/object:Gem::Version
|
98
100
|
version: '0'
|
99
101
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
102
|
+
rubygems_version: 3.5.3
|
103
|
+
signing_key:
|
101
104
|
specification_version: 4
|
102
105
|
summary: Rabbit (Rabbit Messaging)
|
103
106
|
test_files: []
|