two_percent 1.3.0 → 1.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ac252e6553e3c0c261a4040213a21c79a68676d11a5f62acd3b6400bc391f44
4
- data.tar.gz: 4bd46dfb3b2017945cff1e9abca2549634f4d4d68facc8290a5e2345b4264ad1
3
+ metadata.gz: 53622bd4d65e635981958fbad4adfad15ea06dbe16b2d69b7eb5c8078913939f
4
+ data.tar.gz: c56f95670f049bfe0dd806ccc156e72f70247dd7c625de15b1802dd47f96d93e
5
5
  SHA512:
6
- metadata.gz: b3b842f8a44b3b5c58ebc4d9597468a70c970a70550d3a3b64d67f54c88dc67484eb9b30599cc4274db5674584318535fc38a84060b930c25661044938407ef3
7
- data.tar.gz: bfe00f93654f7848d59d43610d70cb018a93f65d13663988a066761fa8291e65014712b54306d7211dfb28fb0f3fe6ae50ca99faa13c71ec3faf75d64f7e630f
6
+ metadata.gz: 6647ffbacfe794c063cdef202259cecca1c2d1fcbbd1a1c820e9dba352d6c3809b3bbcb4d565552ed096162b046eba7c343dad7007de14bbcd79ca3422db71fb
7
+ data.tar.gz: c6c457ff43f0f731e1921f705348f4ee7f14d18128f708522674066fd466bb5515d47116819a2cef03e0a5a2c537903ff355ec163544028c2a4b3f3e8477a666
@@ -13,17 +13,21 @@ module TwoPercent
13
13
  @operations.each do |operation|
14
14
  resource_type, id = parse_path(operation[:path])
15
15
 
16
- # Persist data to two_percent tables first (wrapped in transaction for bulk integrity)
16
+ # Persist data to two_percent tables first (wrapped in transaction for bulk integrity).
17
+ # The transaction commits when this block closes.
18
+ record = nil
17
19
  ActiveRecord::Base.transaction do
18
20
  record = persist_bulk_operation(operation[:method], resource_type, id, operation[:data])
19
-
20
- # Publish domain events based on operation
21
- # Note: DELETE operations don't return a record, but still need to publish events
22
- if record || operation[:method] == "DELETE"
23
- publish_domain_event(operation[:method], resource_type, record,
24
- id)
25
- end
26
21
  end
22
+
23
+ # Publish domain events only AFTER the transaction commits, so any subscriber
24
+ # that reacts to the event can rely on the persisted row being visible.
25
+ # Publishing is intentionally outside the transaction: a publish failure no
26
+ # longer rolls back the write.
27
+ # Note: DELETE operations don't return a record, but still need to publish events.
28
+ next unless record || operation[:method] == "DELETE"
29
+
30
+ publish_domain_event(operation[:method], resource_type, record, id)
27
31
  end
28
32
  end
29
33
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TwoPercent
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: two_percent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares