From f64d2151d08ddb474c5caea93a0a33f6a83a3c97 Mon Sep 17 00:00:00 2001 From: damocles Date: Thu, 5 Nov 2026 10:48:50 +0100 Subject: [PATCH] swarm-nats-auth: let the notify router read its own consumer's counts, which its lag gauges ask for --- swarm-nats-auth/src/policy.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/swarm-nats-auth/src/policy.rs b/swarm-nats-auth/src/policy.rs index 0d5db780..6589fd1e 100644 --- a/swarm-nats-auth/src/policy.rs +++ b/swarm-nats-auth/src/policy.rs @@ -282,9 +282,10 @@ impl Policy { /// /// - **Forge events.** Open or create the stream, create its one durable /// in the extended form whose last tokens are the filter (the server - /// checks them against the payload), pull from it and ack. No bare - /// `CONSUMER.CREATE`, no `CONSUMER.INFO`, no publish on the events: the - /// controller is their one publisher. + /// checks them against the payload), pull from it and ack, and read its + /// own consumer's counts with `CONSUMER.INFO` for the lag gauges. No bare + /// `CONSUMER.CREATE`, no `CONSUMER.INFO` on any other consumer, no + /// publish on the events: the controller is their one publisher. /// - **Todo queue.** Open or create `ROUTER_TODOS` and publish on every /// agent's subject: one per agent, so a wildcard, for the no-roster /// reason the reader's input grant gives. No other grant names these @@ -321,6 +322,7 @@ impl Policy { forge_events::subject_wildcard() ), format!("$JS.API.CONSUMER.MSG.NEXT.{events}.{consumer}"), + format!("$JS.API.CONSUMER.INFO.{events}.{consumer}"), format!("$JS.ACK.{events}.{consumer}.>"), format!("$JS.API.STREAM.INFO.{}", router_todo::STREAM), format!("$JS.API.STREAM.CREATE.{}", router_todo::STREAM), @@ -1927,6 +1929,8 @@ mod tests { forge_events::subject_wildcard() ), format!("$JS.API.CONSUMER.MSG.NEXT.{events}.notify-router"), + // Its own consumer's counts, for the lag gauges. + format!("$JS.API.CONSUMER.INFO.{events}.notify-router"), format!("$JS.ACK.{events}.notify-router.1.5.5.1700000000.0"), format!("$JS.API.STREAM.INFO.{events}"), format!("$JS.API.STREAM.CREATE.{}", router_todo::STREAM), @@ -1956,6 +1960,8 @@ mod tests { format!("$JS.API.CONSUMER.CREATE.{events}"), format!("$JS.API.CONSUMER.CREATE.{events}.other.$SWARM.events.forge.*"), format!("$JS.API.CONSUMER.DELETE.{events}.notify-router"), + // Only its own consumer's counts, not another's. + format!("$JS.API.CONSUMER.INFO.{events}.other"), format!("$JS.API.STREAM.DELETE.{}", router_todo::STREAM), format!("$JS.API.STREAM.UPDATE.{}", router_todo::STREAM), format!(