pub struct JetStreamBackend { /* private fields */ }Expand description
A connected adapter for one team.
Implementations§
Source§impl JetStreamBackend
impl JetStreamBackend
pub const NAME: &'static str = "jetstream"
Sourcepub async fn connect(config: &Config, team_id: Uuid) -> BusResult<Self>
pub async fn connect(config: &Config, team_id: Uuid) -> BusResult<Self>
Connect and adopt the team’s stream. Does not create it: that is
provision, an operator action with a different credential.
Sourcepub async fn provision(config: &Config, team_id: Uuid) -> BusResult<Provisioned>
pub async fn provision(config: &Config, team_id: Uuid) -> BusResult<Provisioned>
Create a team’s body stream, or find it. Operator action: run with the provisioning credential, not the one the server runs with.
An existing stream keeps its limits, whatever config asks for:
a routine retry must never shrink or grow a quota on the quiet.
Provisioned::created and Provisioned::differs_from tell the
caller what happened, and Self::update_quotas is the explicit
way to change them.
Sourcepub async fn provision_inbox(
config: &Config,
team_id: Uuid,
) -> BusResult<Provisioned>
pub async fn provision_inbox( config: &Config, team_id: Uuid, ) -> BusResult<Provisioned>
Create or find a team’s inbox stream. Same operator action and same
credential as provision; separate so a deployment can see what
each stream costs.
Sourcepub async fn check_update(
config: &Config,
team_id: Uuid,
kind: StreamKind,
) -> BusResult<QuotaChange>
pub async fn check_update( config: &Config, team_id: Uuid, kind: StreamKind, ) -> BusResult<QuotaChange>
What changing a stream’s quotas would do, without doing it: the limits it has now (what a rollback restores), what it holds, and the extra bytes the broker would have to reserve. Refused when the stream already holds more than the new ceiling would allow, since a ceiling below the current contents would make the next write fail (bodies) or start dropping (references) at once.
Sourcepub async fn update_quotas(
config: &Config,
team_id: Uuid,
kind: StreamKind,
) -> BusResult<Provisioned>
pub async fn update_quotas( config: &Config, team_id: Uuid, kind: StreamKind, ) -> BusResult<Provisioned>
Change an existing stream’s quotas to what config asks for: the
explicit counterpart of the retry that keeps them. Runs
Self::check_update first. The check is a snapshot: a publisher can
add to the stream between it and the update, so the outcome carries
the contents read back afterwards and the caller says so when they
exceed the new ceiling. Neither stream loses data to that race: the
body stream discards new writes when full, and an inbox reference
the broker drops is rebuilt from Postgres, which is its authority.
Sourcepub async fn apply_update(
config: &Config,
team_id: Uuid,
kind: StreamKind,
change: &QuotaChange,
) -> BusResult<Provisioned>
pub async fn apply_update( config: &Config, team_id: Uuid, kind: StreamKind, change: &QuotaChange, ) -> BusResult<Provisioned>
Apply a change that Self::check_update already vetted.
Sourcepub async fn storage_account(config: &Config) -> BusResult<StorageAccount>
pub async fn storage_account(config: &Config) -> BusResult<StorageAccount>
The broker’s storage account as it stands: bytes used, bytes
reserved by every stream’s max_bytes, and the store’s budget
(None when the account is unlimited). Lets a caller refuse a
change that could not be reserved before touching anything.
Sourcepub async fn publish_reference(
&self,
recipient_key: &str,
event_id: Uuid,
payload: &str,
) -> Published
pub async fn publish_reference( &self, recipient_key: &str, event_id: Uuid, payload: &str, ) -> Published
Publish one reference to a recipient’s own subject.
Deduplicated on the event id, so a retry of the same reference is the same notification rather than a second one.
Sourcepub async fn fetch_references(
&self,
recipient_key: &str,
limit: usize,
) -> BusResult<Vec<InboxRef>>
pub async fn fetch_references( &self, recipient_key: &str, limit: usize, ) -> BusResult<Vec<InboxRef>>
Take up to limit references without acknowledging any of them.
Acknowledgement happens only once the receipt is committed.
Sourcepub async fn ack_reference(&self, ack_subject: &str) -> BusResult<()>
pub async fn ack_reference(&self, ack_subject: &str) -> BusResult<()>
Acknowledge one reference by the subject it was offered on. Sent after the receipt has been committed, never before.
Sourcepub async fn inbox_status(&self, recipient_key: &str) -> BusResult<InboxStatus>
pub async fn inbox_status(&self, recipient_key: &str) -> BusResult<InboxStatus>
What this recipient’s consumer holds. A missing consumer is a fact, not an empty inbox.
Sourcepub async fn deprovision(config: &Config, team_id: Uuid) -> BusResult<()>
pub async fn deprovision(config: &Config, team_id: Uuid) -> BusResult<()>
Remove a team’s stream. Operator action, and a destructive one: it drops every body the stream holds.
pub fn stream(&self) -> &str
Trait Implementations§
Source§impl Clone for JetStreamBackend
impl Clone for JetStreamBackend
Source§impl MessagingBackend for JetStreamBackend
impl MessagingBackend for JetStreamBackend
Source§async fn publish(&self, envelope: Envelope) -> Published
async fn publish(&self, envelope: Envelope) -> Published
publish_key: presented the
same key twice, it returns the same locator rather than storing twice.Source§async fn fetch(
&self,
locator: &Locator,
message_id: Uuid,
) -> BusResult<Option<String>>
async fn fetch( &self, locator: &Locator, message_id: Uuid, ) -> BusResult<Option<String>>
Auto Trait Implementations§
impl !RefUnwindSafe for JetStreamBackend
impl !UnwindSafe for JetStreamBackend
impl Freeze for JetStreamBackend
impl Send for JetStreamBackend
impl Sync for JetStreamBackend
impl Unpin for JetStreamBackend
impl UnsafeUnpin for JetStreamBackend
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> 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