durable_streams-rails 0.8.3 → 0.9.0
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/durable_streams/rails/broadcasts.rb +24 -6
- data/lib/durable_streams/rails/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: 1c1b6bad4d62ec6536e60cd7a1633cb6d6f2beeb569209a75a66a2dc5460210d
|
|
4
|
+
data.tar.gz: a134303459a6f7abde0091da7beadc329a3bf97a6410c05e6a86f0be6c206250
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5ed7326503d8ef2b0848eb00ece27d006510937d0ab2290212d4ea660a93400cd9b3ee5e48e36eeda26f796f1d367d7fb3fb51d925696128550932573fd59d47
|
|
7
|
+
data.tar.gz: f2c9e9bc696dd96988540a04ff8826868dafd65c2529eacff25d6dc8b19802c32a61c63eb767bbcce4cff1d951750b20977853356c1e5db6bab6cc64ea183ec2
|
|
@@ -34,10 +34,8 @@ module DurableStreams::Rails::Broadcasts
|
|
|
34
34
|
|
|
35
35
|
append_to_stream(
|
|
36
36
|
stream_name_from(streamables),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
headers: { operation: operation, txid: txid }
|
|
40
|
-
})
|
|
37
|
+
{ type: type, key: key.to_s, value: value,
|
|
38
|
+
headers: { operation: operation, txid: txid } }.to_json
|
|
41
39
|
)
|
|
42
40
|
|
|
43
41
|
txid
|
|
@@ -45,11 +43,31 @@ module DurableStreams::Rails::Broadcasts
|
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
def broadcast_event_later_to(*streamables, type:, key:, value:, operation:)
|
|
46
|
+
build_broadcast_event_to(*streamables, type: type, key: key, value: value, operation: operation)&.enqueue
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Build the <tt>BroadcastJob</tt> for a State Protocol event without enqueuing it, so a
|
|
50
|
+
# fan-out to many distinct streams can be enqueued in a single Active Job insert via
|
|
51
|
+
# <tt>ActiveJob.perform_all_later</tt> — one bulk insert instead of one +perform_later+ per
|
|
52
|
+
# recipient. Returns +nil+ when streamables are blank, so a collection can be +filter_map+ped
|
|
53
|
+
# straight into +perform_all_later+:
|
|
54
|
+
#
|
|
55
|
+
# jobs = residencies.filter_map { |residency|
|
|
56
|
+
# DurableStreams.build_broadcast_event_to residency.envoy, :residencies,
|
|
57
|
+
# type: "residency", key: residency.sync_id, value: residency.to_h, operation: :update
|
|
58
|
+
# }
|
|
59
|
+
# ActiveJob.perform_all_later(jobs)
|
|
60
|
+
#
|
|
61
|
+
# Turbo has no counterpart: its broadcasts target one stream per call, so it never needs to
|
|
62
|
+
# bulk-enqueue. We fan out per recipient (one stream each), where N separate
|
|
63
|
+
# +broadcast_event_later_to+ calls would be N enqueues. +broadcast_event_later_to+ is defined
|
|
64
|
+
# in terms of this builder (<tt>...&.enqueue</tt>) so job construction lives in one place.
|
|
65
|
+
def build_broadcast_event_to(*streamables, type:, key:, value:, operation:)
|
|
48
66
|
streamables.flatten!
|
|
49
67
|
streamables.compact_blank!
|
|
50
68
|
|
|
51
69
|
if streamables.present?
|
|
52
|
-
DurableStreams::Rails::BroadcastJob.
|
|
70
|
+
DurableStreams::Rails::BroadcastJob.new \
|
|
53
71
|
stream_name_from(streamables),
|
|
54
72
|
type: type, key: key, value: value, operation: operation.to_s
|
|
55
73
|
end
|
|
@@ -60,7 +78,7 @@ module DurableStreams::Rails::Broadcasts
|
|
|
60
78
|
streamables.compact_blank!
|
|
61
79
|
|
|
62
80
|
if streamables.present?
|
|
63
|
-
append_to_stream(stream_name_from(streamables),
|
|
81
|
+
append_to_stream(stream_name_from(streamables), payload.to_json)
|
|
64
82
|
end
|
|
65
83
|
end
|
|
66
84
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: durable_streams-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tokimonki
|
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
requirements: []
|
|
103
|
-
rubygems_version: 4.0.
|
|
103
|
+
rubygems_version: 4.0.13
|
|
104
104
|
specification_version: 4
|
|
105
105
|
summary: Durable Streams integration for Rails
|
|
106
106
|
test_files: []
|