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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a240a2348f45c36bf76377a8edbc3af77cea2caf1c3240f85b68072fbb99cd32
4
- data.tar.gz: 33a71dec75089581641a2ddc1bde47e35994c3e9b5f383ace8865077e3620df1
3
+ metadata.gz: 838bf63855d71b86ca0ce7be93fa36c7b35496d8a450485bd1b8f41c29e76d6e
4
+ data.tar.gz: b37e5777fad8e3d532bf8265513edf89354ffa5b3ce312a5da43b1dfa294165e
5
5
  SHA512:
6
- metadata.gz: cd32451e9af08be2e0c5d3793b34a9c3f23997482304e9783e8dc0bab5b9c01d46e265ae4cb5ed8649429972f28bb51aa8421fdc5ce418aebf4f41a21d99594e
7
- data.tar.gz: a57430bf42f65f452bf20e6d3f468e2c750085b8fc50e558d6ad99f3d39cb317bcfd0a0b3ac13ba8c04eb167001c0be027a32de9abb64c32daa04a1b99dcb604
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
- topic: "my-topic-name" # default transport arguments
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
- topic: "order_created_topic" # some transport default argument
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
- factory.build(**params.symbolize_keys)
83
+ if disposable
84
+ ->(*args) { factory.build(**params).call(*args) }
85
+ else
86
+ factory.build(**params)
87
+ end
83
88
  else
84
- namespace.constantize.new(**params.symbolize_keys)
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
@@ -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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sbmt
4
4
  module Outbox
5
- VERSION = "5.0.1"
5
+ VERSION = "5.0.4"
6
6
  end
7
7
  end
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.1
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-02-29 00:00:00.000000000 Z
11
+ date: 2024-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool