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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32b7136264c3c58bf1d1abafec7d87de85527739a1eebfd099042df478fbeb9a
4
- data.tar.gz: 4cad011b7effea1efeb9f9be19845ed8b5652e0ccce7e2c8971723d9fc661043
3
+ metadata.gz: 1e6aafc0e3245798247add32c7232b17e7c54384f9ffbd58eaad6dcb64acd85b
4
+ data.tar.gz: 5729cbb4cc772f1c4bf44c343294a28ecd43a3b2990846984b77ae6bf2d3f25e
5
5
  SHA512:
6
- metadata.gz: fb55c88972044fd2888e7798df09283878acaccfbd077330b2025908482f6fc9f82c90cdeb8cbd40aecf5cbc421728867da8495034c0e24ae2e6cf37e9a91441
7
- data.tar.gz: b4a27e45cf852435c8a374654c8ddfb0fcb664a6a92712aa308ab9649bff4e091a7a0c11419d41c08b0632f0138608d7755c34a1d74300f7e68274fbf51b5a64
6
+ metadata.gz: 18f62ee08b52c3246844d1432c9e9890070a32f48ab84cad3f24e3af45cbdc254a737ed2ac67a7be2691e74c914fe90f80940ff4ad451ea7b86a36a043bc2ee2
7
+ data.tar.gz: fd42543375e15f3ec827e0b7699e60f60bc4785562a8e91c6a2ce168ce5a78e3f099e1cc211f7861294f54569417931c01287917913f75ac37cee1ba884ab7e2
@@ -1,3 +1,3 @@
1
1
  module DurableStreams
2
- RAILS_VERSION = "0.2.4"
2
+ RAILS_VERSION = "0.2.5"
3
3
  end
@@ -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
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - tokimonki