Skip to main content

Mirror

Struct Mirror 

Source
pub struct Mirror<'o, O: ObjectStore> { /* private fields */ }
Expand description

A store directory ⇄ object store link. See the crate docs.

Implementations§

Source§

impl<'o, O: ObjectStore> Mirror<'o, O>

Source

pub fn new(objects: &'o O, prefix: &str) -> Result<Self>

Mirror under prefix (empty, or a key prefix such as "kb/runbooks"; a trailing / is implied).

Source

pub fn encode_bases(self, encoding: ContentEncoding) -> Self

Publish every new base with encoding (feature gzip). Bases only: HEAD and log segments are never encoded. Readers need no setting — get decodes. Published::uploaded still counts the store’s bytes, not the smaller stored ones.

Source

pub fn prefix(&self) -> &str

The normalized prefix (empty or ending in /).

Source

pub fn lease(&self) -> Option<Lease>

The lease recorded in the last HEAD this mirror saw.

Source

pub fn load_image(&self) -> impl Future<Output = Result<Option<Store>>> + '_

Serve the published store straight from memory — no directory, no file writes: the base is used in place (Store::open_image). None when nothing has been published. Keep it current with Mirror::refresh_image.

Source

pub fn refresh_image<'a>( &'a self, store: &'a Store, ) -> impl Future<Output = Result<bool>> + 'a

Keep a Mirror::load_image replica current: one metadata request when nothing changed, only the new log bytes when the log grew, the new base after a compaction. Returns true when anything new became visible.

Source

pub fn pull_into<'a>( &'a self, dir: &'a Path, ) -> impl Future<Output = Result<Option<Pulled>>> + 'a

Rebuild graph.base and graph.wal in dir from the published store, then open it with graph_r::Store::open. None (and dir untouched) when nothing has been published. Refused with graph_r::Error::Locked while another holder has the directory’s writer lock. A writable store with dir open either holds that lock for its life (graph-r 0.4) or takes it per commit (0.5), in which case its next commit builds on the pulled state.

Source

pub fn refresh_into<'a>( &'a self, store: &'a Store, ) -> impl Future<Output = Result<bool>> + 'a

Keep a read-only replica current: store must have been opened with graph_r::Store::open_read_only on a directory this mirror pulled. Returns true when anything new became visible.

Source

pub fn publish<'a>( &'a self, store: &'a Store, ) -> impl Future<Output = Result<Published>> + 'a

Ship what store committed since the last publish. See the crate docs; Error::Fenced means another writer owns the published store.

Source

pub fn acquire_lease<'a>( &'a self, holder: &'a str, ttl_ms: u64, ) -> impl Future<Output = Result<Lease>> + 'a

Become (or stay) the designated writer for ttl_ms. Every Mirror::publish renews it. Refused with Error::Leased while someone else’s lease is unexpired. Clocks of competing instances are assumed to agree to well within ttl_ms.

Source

pub fn release_lease(&self) -> impl Future<Output = Result<()>> + '_

Give the lease up (no-op unless this mirror holds it).

Trait Implementations§

Source§

impl<'o, O: Debug + ObjectStore> Debug for Mirror<'o, O>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'o, O> !Freeze for Mirror<'o, O>

§

impl<'o, O> RefUnwindSafe for Mirror<'o, O>

§

impl<'o, O> Send for Mirror<'o, O>
where &'o O: Send,

§

impl<'o, O> Sync for Mirror<'o, O>
where &'o O: Sync,

§

impl<'o, O> Unpin for Mirror<'o, O>
where &'o O: Unpin,

§

impl<'o, O> UnsafeUnpin for Mirror<'o, O>

§

impl<'o, O> UnwindSafe for Mirror<'o, O>

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
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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