Skip to main content

Repos

Struct Repos 

Source
pub struct Repos {
    inner: Arc<Inner>,
}
Expand description

The producer: the sequence and the replay buffer consumers read from.

One per server. Hand a clone to Provisioner::with_repo_sink and the same one to app_with_repos; every clone shares Inner.

Fields§

§inner: Arc<Inner>

Implementations§

Source§

impl Repos

Source

pub fn new(sequence: Arc<Sequence>, bounds: ReplayBounds) -> Self

Builds a producer numbering frames from sequence and holding up to bounds of them for replay.

Source

pub fn booting( sequence: Arc<Sequence>, bounds: ReplayBounds, log: Option<Arc<Wal>>, ) -> Result<Self>

Builds a producer for a boot: it holds every frame numbered until Self::listening, and bounds more after it.

With log, the write-ahead log commits are written to, a commit is published only once log has synced past it. See the module docs.

§Errors

The thread that publishes held commits would not start.

Source

fn build( sequence: Arc<Sequence>, bounds: ReplayBounds, booting: bool, held: Option<Arc<Held>>, ) -> Self

Source

pub fn listening(&self)

Ends the boot Self::booting began: the buffer keeps every frame the boot numbered, and holds Self::bounds more on top of them, with the same slack for frames a stream has not sent.

Called once the listener is bound. Nothing before that could have read a frame, and a relay that reconnects after a boot is owed every one the boot numbered. A producer that is not booting is left as it is.

Source

pub fn newest(&self) -> u64

The newest sequence number assigned, or the restart floor if none has been.

Source

pub fn subscribers(&self) -> usize

How many streams are open right now.

The per-connection state this producer holds is one receiver of published and one of closing, so this figure is the whole of it: a consumer that hung up and left its receiver behind would show up here and nowhere else. Observability rather than a bound — nothing refuses a subscriber for being the n-th — and the number a test watches to see a departed consumer actually freed.

Source

pub fn bounds(&self) -> ReplayBounds

How much the replay buffer holds at most, once any boot is over.

Source

fn ring(&self) -> MutexGuard<'_, Ring>

Source

fn start_for(&self, resume: Resume, newest: u64) -> Start

Where a consumer resuming from resume starts, decided under one acquisition of the ring lock, which also registers its stream so the frames after its start are kept for it.

One acquisition for the whole decision, which is what makes the outdated answer true of the position beside it. Measuring the buffer and then reading it takes two acquisitions, and a publish landing between them evicts the very frame the cursor was just tested against: the consumer is then handed a later start with no #info OutdatedCursor in front of it, and believes it applied everything. A frame evicted after the decision is the stream’s to notice, in ReposStream::next.

Source

pub fn publish_commit(&self, event: &RepoCommit) -> Option<Frame>

Numbers, encodes, buffers and publishes one commit.

Returns the frame so a caller — a test, mostly — can see what went out, and None when the stream could not number it: a frame numbered over a reservation that did not reach the log wears a number the next run will hand out again. See didbot_pds::Sequence::next.

Source

pub fn publish_identity(&self, event: &RepoIdentity) -> Option<Frame>

Numbers, encodes, buffers and publishes one identity event.

Source

pub fn publish_account(&self, event: &RepoAccount) -> Option<Frame>

Numbers, encodes, buffers and publishes one account event.

Source

pub fn publish_sync(&self, event: &RepoSync) -> Option<Frame>

Numbers, encodes, buffers and publishes one repository reset.

Source

fn publish( &self, kind: FrameKind, body: impl FnOnce(u64) -> Value, ) -> Option<Frame>

Numbers a frame, puts it in the buffer and hands it to the live channel, under one lock.

None when the number could not be reserved durably. The event is not buffered and not sent: a frame numbered over a reservation that did not land wears a number the next run will hand out again, and the consumer holding it as a cursor is told nothing. See didbot_pds::Sequence::next.

Source

fn publish_locked( &self, ring: &mut Ring, kind: FrameKind, body: impl FnOnce(u64) -> Value, ) -> Option<Frame>

Self::publish, under a ring lock the caller holds.

Source

pub fn release(&self)

Syncs the log and publishes every commit held back for it, oldest first.

A clean shutdown calls this once serving has stopped, so the commits held back go out before Self::close ends the streams.

Source

fn release_synced(&self)

Publishes every held commit the log has synced past, oldest first.

Source

fn release_locked(&self, ring: &mut Ring)

Source

fn sync_held_log(&self)

Syncs the log the held commits are in, when there is one.

Source

fn publish_after_held( &self, kind: FrameKind, body: impl FnOnce(u64) -> Value, ) -> Option<Frame>

Publishes a frame that is not a commit, after every commit handed over before it. See the module docs.

Source

pub fn close(&self)

Ends every consumer’s stream once it has sent what is already published.

A subscribeRepos connection outlives the server that upgraded it until this process exits. A clean shutdown calls this after Self::release, so each connection sends what it holds, closes and gives its slot back. See Self::detached.

Source

pub async fn detached(&self, timeout: Duration) -> usize

Waits, for at most timeout, until no consumer is attached. Answers how many still are.

Source

pub fn subscribe( &self, cursor: Option<i64>, exclude: Exclusions, ) -> Result<ReposStream, Vec<u8>>

Opens one connection’s stream, resuming from cursor if it can.

Err is the frame to send before closing, which is how the lexicon’s declared errors go out: an error is a frame on the socket, not an HTTP status, because by the time a cursor has been read the upgrade has already happened.

Trait Implementations§

Source§

impl Clone for Repos

Source§

fn clone(&self) -> Repos

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Repos

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Repos

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl RepoEventSink for Repos

A commit is held when the producer is over a log; every other frame publishes after the commits held before it. See the module docs.

Source§

fn commit(&self, event: &RepoCommit)

Delivers one commit, with the blocks it created. Read more
Source§

fn identity(&self, event: &RepoIdentity)

Says an account’s DID document is worth re-resolving.
Source§

fn account(&self, event: &RepoAccount) -> bool

Says whether an account’s repository can still be fetched here. Read more
Source§

fn sync(&self, event: &RepoSync) -> bool

Says a repository was reset to a new commit. Answers whether the frame was numbered.

Auto Trait Implementations§

§

impl Freeze for Repos

§

impl !RefUnwindSafe for Repos

§

impl Send for Repos

§

impl Sync for Repos

§

impl Unpin for Repos

§

impl UnsafeUnpin for Repos

§

impl !UnwindSafe for Repos

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,