sbmt-outbox 5.0.1 → 5.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/app/models/sbmt/outbox/base_item_config.rb +12 -2
- data/lib/sbmt/outbox/engine.rb +1 -0
- data/lib/sbmt/outbox/version.rb +1 -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: 838bf63855d71b86ca0ce7be93fa36c7b35496d8a450485bd1b8f41c29e76d6e
|
4
|
+
data.tar.gz: b37e5777fad8e3d532bf8265513edf89354ffa5b3ce312a5da43b1dfa294165e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10ecf87fd36a86a85a29e003d4335cee56751a30720ff58fa7aa52395d3118eb1bb168c9685422da2f7dee758c34dc47b8ee32e8ecd0ec8bd103b83d8e041716
|
7
|
+
data.tar.gz: 756e0a98911120354c14c27ca6732272c51c470a8fd2393d9318d60b60de126c959cf297c84a8b8c4ee75a26a2e48ae74396fd57f8d24a138cc849841da2be1f
|
data/README.md
CHANGED
@@ -23,6 +23,10 @@ And then execute:
|
|
23
23
|
bundle install
|
24
24
|
```
|
25
25
|
|
26
|
+
## Demo
|
27
|
+
|
28
|
+
Learn how to use this gem and how it works with Ruby on Rails at here https://github.com/SberMarket-Tech/outbox-example-apps
|
29
|
+
|
26
30
|
## Auto configuration
|
27
31
|
|
28
32
|
We recommend going through the configuration and files creation process using the following Rails generators:
|
@@ -146,7 +150,11 @@ default: &default
|
|
146
150
|
max_retries: 3 # default 0, the number of retries before the item will be marked as failed
|
147
151
|
transports: # transports section
|
148
152
|
produce_message: # underscored transport class name
|
149
|
-
|
153
|
+
# transport reserved options
|
154
|
+
class: produce_message # optional; default is inferred from transport name
|
155
|
+
disposable: false # optional; default false; if true, the transport class will be instantiated only once
|
156
|
+
# ProduceMessage instance arguments
|
157
|
+
topic: "my-topic-name"
|
150
158
|
|
151
159
|
development:
|
152
160
|
<<: *default
|
@@ -182,9 +190,11 @@ Transports are defined as follows when `event_name` is used:
|
|
182
190
|
outbox_items:
|
183
191
|
my_outbox_item:
|
184
192
|
transports:
|
193
|
+
# transport reserved options
|
185
194
|
- class: produce_message
|
186
195
|
event_name: "order_created" # event name marker
|
187
|
-
|
196
|
+
# ProduceMessage instance arguments
|
197
|
+
topic: "order_created_topic" # some transport argument
|
188
198
|
- class: produce_message
|
189
199
|
event_name: "orders_completed"
|
190
200
|
topic: "orders_completed_topic"
|
@@ -76,12 +76,22 @@ module Sbmt
|
|
76
76
|
memo[event_name] ||= []
|
77
77
|
namespace = params.delete(:class)&.camelize
|
78
78
|
raise ArgumentError, "Transport name cannot be blank" if namespace.blank?
|
79
|
+
disposable = params.key?(:disposable) ? params.delete(:disposable) : Outbox.config.disposable_transports
|
79
80
|
|
80
81
|
factory = "#{namespace}::OutboxTransportFactory".safe_constantize
|
81
82
|
memo[event_name] << if factory
|
82
|
-
|
83
|
+
if disposable
|
84
|
+
->(*args) { factory.build(**params).call(*args) }
|
85
|
+
else
|
86
|
+
factory.build(**params)
|
87
|
+
end
|
83
88
|
else
|
84
|
-
namespace.constantize
|
89
|
+
klass = namespace.constantize
|
90
|
+
if disposable
|
91
|
+
->(*args) { klass.new(**params).call(*args) }
|
92
|
+
else
|
93
|
+
klass.new(**params)
|
94
|
+
end
|
85
95
|
end
|
86
96
|
end
|
87
97
|
end
|
data/lib/sbmt/outbox/engine.rb
CHANGED
@@ -14,6 +14,7 @@ module Sbmt
|
|
14
14
|
c.outbox_item_classes = []
|
15
15
|
c.inbox_item_classes = []
|
16
16
|
c.paths = []
|
17
|
+
c.disposable_transports = false
|
17
18
|
c.redis = {url: ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379")}
|
18
19
|
c.process_items = ActiveSupport::OrderedOptions.new.tap do |c|
|
19
20
|
c.general_timeout = 120
|
data/lib/sbmt/outbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbmt-outbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sbermarket Ruby-Platform Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|