durable_streams-rails 0.2.4 → 0.2.5
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/version.rb +1 -1
- data/lib/durable_streams-rails.rb +14 -0
- 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: 1e6aafc0e3245798247add32c7232b17e7c54384f9ffbd58eaad6dcb64acd85b
|
|
4
|
+
data.tar.gz: 5729cbb4cc772f1c4bf44c343294a28ecd43a3b2990846984b77ae6bf2d3f25e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18f62ee08b52c3246844d1432c9e9890070a32f48ab84cad3f24e3af45cbdc254a737ed2ac67a7be2691e74c914fe90f80940ff4ad451ea7b86a36a043bc2ee2
|
|
7
|
+
data.tar.gz: fd42543375e15f3ec827e0b7699e60f60bc4785562a8e91c6a2ce168ce5a78e3f099e1cc211f7861294f54569417931c01287917913f75ac37cee1ba884ab7e2
|
|
@@ -30,6 +30,7 @@ module DurableStreams
|
|
|
30
30
|
|
|
31
31
|
def signed_stream_url(*streamables, expires_in: 24.hours)
|
|
32
32
|
path = stream_name_from(streamables)
|
|
33
|
+
ensure_stream_exists(path)
|
|
33
34
|
token = signed_stream_verifier.generate(path, expires_in: expires_in)
|
|
34
35
|
"#{base_url}/#{path}?token=#{token}"
|
|
35
36
|
end
|
|
@@ -47,5 +48,18 @@ module DurableStreams
|
|
|
47
48
|
Rack::Utils.parse_query(query)["token"]
|
|
48
49
|
end
|
|
49
50
|
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
# Creates the stream on the server if it doesn't already exist. Called automatically
|
|
54
|
+
# by +signed_stream_url+ so clients can subscribe immediately without hitting a 404.
|
|
55
|
+
# Idempotent — the server returns 200 when the stream already exists with matching config.
|
|
56
|
+
# Skipped during tests (no server) and when base_url is not configured.
|
|
57
|
+
def ensure_stream_exists(stream_name)
|
|
58
|
+
return if DurableStreams::Testing.recording?
|
|
59
|
+
|
|
60
|
+
stream(stream_name).create_stream(content_type: "application/json")
|
|
61
|
+
rescue DurableStreams::StreamExistsError
|
|
62
|
+
# Already exists with different config — still usable
|
|
63
|
+
end
|
|
50
64
|
end
|
|
51
65
|
end
|