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 +4 -4
- data/lib/two_percent/bulk_processor.rb +12 -8
- data/lib/two_percent/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53622bd4d65e635981958fbad4adfad15ea06dbe16b2d69b7eb5c8078913939f
|
|
4
|
+
data.tar.gz: c56f95670f049bfe0dd806ccc156e72f70247dd7c625de15b1802dd47f96d93e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
data/lib/two_percent/version.rb
CHANGED