pub struct DistributedBus { /* private fields */ }Expand description
Clustered EventBus: a doorbell over the durable store (spec §3.2).
Implementations§
Source§impl DistributedBus
impl DistributedBus
Sourcepub async fn connect(url: &str, store: Arc<dyn Store>) -> Result<Self>
pub async fn connect(url: &str, store: Arc<dyn Store>) -> Result<Self>
Build a bus on its own pool. Each live subscription pins one connection
for its LISTEN, so the pool is sized above sqlx’s default of 10 to
allow a useful SSE fan-out before subscribe/publish start queuing on
the pool; raise it further (or share a pool) for high-fan-out deployments.
Sourcepub fn new(pool: PgPool, store: Arc<dyn Store>) -> Self
pub fn new(pool: PgPool, store: Arc<dyn Store>) -> Self
Build a bus on an existing pool (shared-pool wiring — size the pool for
the SSE fan-out, since each subscription pins a LISTEN connection).
Sourcepub async fn subscribe_all_ready(&self) -> Result<BusSubscription>
pub async fn subscribe_all_ready(&self) -> Result<BusSubscription>
EventBus::subscribe_all, but the LISTEN is established before
this returns rather than lazily on the stream’s first poll (#132).
The lazy form cannot tell a caller when it is safe to publish. A doorbell rung in the gap is simply not heard, and because the per-key high-water starts at 0, the miss is only repaired by the next doorbell for that key — which, for a stream that just went quiet, may never come. Ringing repeatedly and hoping is what the #132 test was doing, and it still starved to zero deliveries on a contended runner.
Connection and LISTEN failures surface here as an Err instead of
silently ending the stream, which is the other thing the lazy form
cannot express.
Trait Implementations§
Source§impl EventBus for DistributedBus
impl EventBus for DistributedBus
Source§fn publish(&self, event: FleetEvent)
fn publish(&self, event: FleetEvent)
Source§fn subscribe(&self, stream_key: &str) -> BusSubscription
fn subscribe(&self, stream_key: &str) -> BusSubscription
stream_key; consumers dedup the
initial-history/live overlap on seq.Source§fn subscribe_all(&self) -> BusSubscription
fn subscribe_all(&self) -> BusSubscription
FleetManager::watch_changes) that can’t name
a stream key in advance — a brand-new agent’s own id keys its
AgentDiscovered event, so no one can pre-subscribe to it by key.Auto Trait Implementations§
impl !RefUnwindSafe for DistributedBus
impl !UnwindSafe for DistributedBus
impl Freeze for DistributedBus
impl Send for DistributedBus
impl Sync for DistributedBus
impl Unpin for DistributedBus
impl UnsafeUnpin for DistributedBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more