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>
impl<'o, O: ObjectStore> Mirror<'o, O>
Sourcepub fn new(objects: &'o O, prefix: &str) -> Result<Self>
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).
Sourcepub fn encode_bases(self, encoding: ContentEncoding) -> Self
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.
Sourcepub fn load_image(&self) -> impl Future<Output = Result<Option<Store>>> + '_
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.
Sourcepub fn refresh_image<'a>(
&'a self,
store: &'a Store,
) -> impl Future<Output = Result<bool>> + 'a
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.
Sourcepub fn pull_into<'a>(
&'a self,
dir: &'a Path,
) -> impl Future<Output = Result<Option<Pulled>>> + 'a
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.
Sourcepub fn refresh_into<'a>(
&'a self,
store: &'a Store,
) -> impl Future<Output = Result<bool>> + 'a
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.
Sourcepub fn publish<'a>(
&'a self,
store: &'a Store,
) -> impl Future<Output = Result<Published>> + 'a
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.
Sourcepub fn acquire_lease<'a>(
&'a self,
holder: &'a str,
ttl_ms: u64,
) -> impl Future<Output = Result<Lease>> + 'a
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.
Sourcepub fn release_lease(&self) -> impl Future<Output = Result<()>> + '_
pub fn release_lease(&self) -> impl Future<Output = Result<()>> + '_
Give the lease up (no-op unless this mirror holds it).