pgbus 0.6.3 → 0.6.4

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: 97572298add12c78b7d9f3ebb6a50af36a9803380d42202a66031ce7f1018d4c
4
- data.tar.gz: b5498b051a4c1d134c2944d1b0c556124fef49a7276ee32cbe0172fac12f6c8d
3
+ metadata.gz: 29a8cea3845cee18f561a257dd07a7793b44b2b7f49cdfa7cf520de2bf95cde2
4
+ data.tar.gz: bbc2e2bddf762b5e8add4bf5d83767afa089aaf2345fbb5c0c3f0018e8be62df
5
5
  SHA512:
6
- metadata.gz: ec8b0af9bac7c6156b12effa0ce3d3ecf9a29f06c091f5117c5567114c00f44c6dea26666306ff9b084c0b616aa3e47b5080d986c1159fcedf64e5fbfe1f909a
7
- data.tar.gz: 0227ab4f57df35bd89c4dac8a022df20a16d8c30eaaff0cbc75c8a49e8debf9dba62e1fb54b1ac26c327aab6199398ac2fe1575db9b1ad1062fb0d6b21083ffc
6
+ metadata.gz: c539792bc228074715f4903a34cfd2e84d7145d08676049dc7b8ef3ef26edc1f66f6fab8c3f5f527ca8b51e84570217d36499e810e6290fb96d1f76575e711e2
7
+ data.tar.gz: 20bd68684e632377de4691845bf26e92848095aa9cf528a7d401931d239b133354d491f90f32b3c294ca03240760d746624f408d50667a562062e563ce484c7e
@@ -75,22 +75,34 @@ module Pgbus
75
75
  end
76
76
  end
77
77
 
78
- # Build the SSE endpoint URL by asking the engine where its
79
- # `:streams` mount point lives, then appending the signed name.
80
- # The base comes from Pgbus::Engine.routes.url_helpers.streams_path
81
- # so the URL follows whatever mount point the host app chose for
82
- # the engine ("/pgbus", "/admin/dashboard", etc.). A
83
- # `NoMethodError` fallback covers the test-only context where
84
- # the helper is included in a plain class outside a Rails
85
- # request and the engine's url_helpers aren't wired in.
78
+ # Build the SSE endpoint URL for the given signed stream name.
79
+ #
80
+ # Resolution order:
81
+ # 1. `config.streams_path` explicit override, useful when the
82
+ # engine is mounted behind an auth constraint but the SSE
83
+ # endpoint is mounted publicly at a separate path:
84
+ #
85
+ # # config/routes.rb
86
+ # authenticate :user, ->(u) { u.admin? } do
87
+ # mount Pgbus::Engine => "/admin/jobs"
88
+ # end
89
+ # mount Pgbus::Web::StreamApp.new => "/pgbus/streams"
90
+ #
91
+ # # config/initializers/pgbus.rb
92
+ # Pgbus.configure { |c| c.streams_path = "/pgbus/streams" }
93
+ #
94
+ # 2. Engine route helper — derives the path from wherever the
95
+ # host app mounted the engine.
96
+ #
97
+ # 3. Fallback `/pgbus/streams` — test-only context where the
98
+ # engine's url_helpers aren't wired in.
86
99
  def pgbus_stream_src(signed_name)
100
+ base = Pgbus.configuration.streams_path
101
+ return "#{base.delete_suffix("/")}/#{signed_name}" if base
102
+
87
103
  base = Pgbus::Engine.routes.url_helpers.streams_path
88
104
  "#{base}/#{signed_name}"
89
105
  rescue NameError
90
- # NameError covers both uninitialized-constant (Pgbus::Engine
91
- # not loaded, e.g. plain-Ruby unit specs) and NoMethodError
92
- # (a NameError subclass) when the routes helper chain isn't
93
- # wired in.
94
106
  "/pgbus/streams/#{signed_name}"
95
107
  end
96
108
 
@@ -90,7 +90,7 @@ module Pgbus
90
90
  :metrics_enabled
91
91
 
92
92
  # Streams (turbo-rails replacement, SSE-based)
93
- attr_accessor :streams_enabled, :streams_queue_prefix, :streams_signed_name_secret,
93
+ attr_accessor :streams_enabled, :streams_path, :streams_queue_prefix, :streams_signed_name_secret,
94
94
  :streams_default_retention, :streams_retention, :streams_heartbeat_interval,
95
95
  :streams_max_connections, :streams_idle_timeout, :streams_listen_health_check_ms,
96
96
  :streams_write_deadline_ms, :streams_falcon_streaming_body,
@@ -168,6 +168,7 @@ module Pgbus
168
168
  @metrics_enabled = true
169
169
 
170
170
  @streams_enabled = true
171
+ @streams_path = nil
171
172
  @streams_queue_prefix = "pgbus_stream"
172
173
  @streams_signed_name_secret = nil
173
174
  @streams_default_retention = 5 * 60 # 5 minutes
data/lib/pgbus/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pgbus
4
- VERSION = "0.6.3"
4
+ VERSION = "0.6.4"
5
5
  end
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.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson