sbmt-outbox 5.0.0 → 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: ade6bbd7b09d15191e05854d0f9b6ffbb9c3d13270b70c417f4064059bd4c986
4
- data.tar.gz: cb315c2a3bf2d42c7836358bb848a58ef8aecd2e5c58a23e216ad849c9bbb705
3
+ metadata.gz: 838bf63855d71b86ca0ce7be93fa36c7b35496d8a450485bd1b8f41c29e76d6e
4
+ data.tar.gz: b37e5777fad8e3d532bf8265513edf89354ffa5b3ce312a5da43b1dfa294165e
5
5
  SHA512:
6
- metadata.gz: 8584326986eb5be82b5d8a64ae9c6f3acd1a9702d91f2fffa980f5da4a8a8a344c6c184f24ab9fa9ad96f480d2d7c35f9cae615de6e64a5231697e928b5f6a97
7
- data.tar.gz: ac0fc97998938b1410bd6df209baea1f387129e5b368e785115e690e2cc7899980595787ae0908dc7e8d6ee1a1a16f201c18e299b7156d32c849495f71fa9b1c
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"
@@ -58,6 +58,22 @@ module Sbmt
58
58
  self.uuid ||= SecureRandom.uuid if has_attribute?(:uuid)
59
59
  end
60
60
 
61
+ def proto_payload
62
+ if has_attribute?(:payload)
63
+ payload
64
+ else
65
+ self[:proto_payload]
66
+ end
67
+ end
68
+
69
+ def proto_payload=(value)
70
+ if has_attribute?(:payload)
71
+ self.payload = value
72
+ else
73
+ self[:proto_payload] = value
74
+ end
75
+ end
76
+
61
77
  def payload
62
78
  if has_attribute?(:proto_payload)
63
79
  proto_payload
@@ -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.0"
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.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-02-27 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