pgbus 0.6.5 → 0.6.6
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/pgbus/engine.rb +9 -0
- data/lib/pgbus/streams/turbo_stream_override.rb +40 -0
- data/lib/pgbus/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a4669f7150717428ced89a13b5c8e7f9cf5d61d6eae6b19919d6408fefad06a
|
|
4
|
+
data.tar.gz: 4dc1c6db2f50ce6e0de5c845cd2813cbb299ad096dab2dcfa5169db368dfa0af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3184e872126937ec8660530143c610a64a0649bd60ab7c9bca6663e6883af3ec16144cfb3d7b74713ff0a5487b7f1edacba973e387a52f802237f9ff3a2c7b2c
|
|
7
|
+
data.tar.gz: bc0f72ace6413ad27899d7968b3fe6df822fd35f3b495bdbf24ccd95c9add029f5ebb3b11e462c0a30937bfca3082460e3c655533464becf73d6cb328ded8621
|
data/lib/pgbus/engine.rb
CHANGED
|
@@ -84,6 +84,15 @@ module Pgbus
|
|
|
84
84
|
# `_` keeps RuboCop's Lint/Void from deleting the line.
|
|
85
85
|
_autoload_trigger = Pgbus::Streams::TurboBroadcastable
|
|
86
86
|
Pgbus::Streams.install_turbo_broadcastable_patch!
|
|
87
|
+
|
|
88
|
+
# Subscribe-side patch: override turbo_stream_from to render
|
|
89
|
+
# <pgbus-stream-source> (SSE) instead of <turbo-cable-stream-source>
|
|
90
|
+
# (ActionCable). Without this, third-party gems like
|
|
91
|
+
# hotwire-livereload that call turbo_stream_from in their views
|
|
92
|
+
# subscribe via ActionCable while the broadcast (patched above)
|
|
93
|
+
# goes through PGMQ — the message never arrives.
|
|
94
|
+
_autoload_trigger_override = Pgbus::Streams::TurboStreamOverride
|
|
95
|
+
Pgbus::Streams.install_turbo_stream_override!
|
|
87
96
|
end
|
|
88
97
|
end
|
|
89
98
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pgbus
|
|
4
|
+
module Streams
|
|
5
|
+
# Runtime patch that redirects `turbo_stream_from` (the view helper)
|
|
6
|
+
# through `pgbus_stream_from` when pgbus streams are enabled. This is
|
|
7
|
+
# the subscribe-side counterpart to `TurboBroadcastable` (which patches
|
|
8
|
+
# the publish-side `broadcast_stream_to`).
|
|
9
|
+
#
|
|
10
|
+
# Without this patch, third-party gems like hotwire-livereload call
|
|
11
|
+
# `turbo_stream_from "hotwire-livereload"` in their views, which
|
|
12
|
+
# renders a `<turbo-cable-stream-source>` element connected to
|
|
13
|
+
# ActionCable. Meanwhile, the `TurboBroadcastable` patch routes the
|
|
14
|
+
# broadcast through PGMQ/SSE. Publisher and subscriber end up on
|
|
15
|
+
# different transports — the message never arrives.
|
|
16
|
+
#
|
|
17
|
+
# After this patch, `turbo_stream_from` renders a `<pgbus-stream-source>`
|
|
18
|
+
# element instead, so both sides use PGMQ/SSE. When `streams_enabled`
|
|
19
|
+
# is false, the original turbo-rails behavior is preserved via `super`.
|
|
20
|
+
module TurboStreamOverride
|
|
21
|
+
def turbo_stream_from(*streamables, **attributes)
|
|
22
|
+
if Pgbus.configuration.streams_enabled
|
|
23
|
+
pgbus_stream_from(*streamables, **attributes)
|
|
24
|
+
else
|
|
25
|
+
super
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Apply the patch to Turbo::StreamsHelper. Idempotent: prepending the
|
|
31
|
+
# same module twice is a no-op. Called from Pgbus::Engine's initializer
|
|
32
|
+
# when both turbo-rails and pgbus streams are enabled.
|
|
33
|
+
def self.install_turbo_stream_override!
|
|
34
|
+
return unless defined?(::Turbo::StreamsHelper)
|
|
35
|
+
return if ::Turbo::StreamsHelper.ancestors.include?(TurboStreamOverride)
|
|
36
|
+
|
|
37
|
+
::Turbo::StreamsHelper.prepend(TurboStreamOverride)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/pgbus/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pgbus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mikael Henriksson
|
|
@@ -297,6 +297,7 @@ files:
|
|
|
297
297
|
- lib/pgbus/streams/presence.rb
|
|
298
298
|
- lib/pgbus/streams/signed_name.rb
|
|
299
299
|
- lib/pgbus/streams/turbo_broadcastable.rb
|
|
300
|
+
- lib/pgbus/streams/turbo_stream_override.rb
|
|
300
301
|
- lib/pgbus/streams/watermark_cache_middleware.rb
|
|
301
302
|
- lib/pgbus/uniqueness.rb
|
|
302
303
|
- lib/pgbus/version.rb
|