Skip to main content

RefBackend

Trait RefBackend 

Source
pub trait RefBackend: CoreRefBackend<Error = HeddleError> {
    // Required methods
    fn get_remote_thread(
        &self,
        remote: &str,
        thread: &ThreadName,
    ) -> Result<Option<StateId>>;
    fn set_remote_thread(
        &self,
        remote: &str,
        thread: &ThreadName,
        state: &StateId,
    ) -> Result<()>;
    fn delete_remote_thread(
        &self,
        remote: &str,
        thread: &ThreadName,
    ) -> Result<Option<StateId>>;
    fn list_remotes(&self) -> Result<Vec<String>>;
    fn list_remote_threads(&self, remote: &str) -> Result<Vec<ThreadName>>;

    // Provided methods
    fn commit_and_publish(
        &self,
        encoded_records: &[Vec<u8>],
        ref_updates: &[RefUpdate],
        scope: Option<&str>,
    ) -> Result<()> { ... }
    fn inspect_ref_summary_index(&self) -> Result<RefSummaryIndexInspection> { ... }
    fn rebuild_ref_summary_index(&self) -> Result<RefSummaryIndexInspection> { ... }
    fn pack_refs(&self) -> Result<()> { ... }
    fn cleanup_stale_temps(&self) { ... }
}
Expand description

Backend-agnostic interface for reading and writing repository references.

Required Methods§

Source

fn get_remote_thread( &self, remote: &str, thread: &ThreadName, ) -> Result<Option<StateId>>

Source

fn set_remote_thread( &self, remote: &str, thread: &ThreadName, state: &StateId, ) -> Result<()>

Source

fn delete_remote_thread( &self, remote: &str, thread: &ThreadName, ) -> Result<Option<StateId>>

Source

fn list_remotes(&self) -> Result<Vec<String>>

Source

fn list_remote_threads(&self, remote: &str) -> Result<Vec<ThreadName>>

Provided Methods§

Source

fn commit_and_publish( &self, encoded_records: &[Vec<u8>], ref_updates: &[RefUpdate], scope: Option<&str>, ) -> Result<()>

The write chokepoint (heddle#330 §2.2 r18): append the caller-supplied ref-carrying record batch (phase 4, opaque rmp-serde OpRecord bytes so refs names no oplog type) before publishing the atomic ref batch (phase 5), record-before-publish. The seam is per backend: the file backend (RefManager) earns atomicity by oplog-append-then-publish + per-read reconciliation; the Postgres backend would co-commit the record row and ref/head rows in one SQL transaction (native ACID).

The default publishes without a record — backends with an injected committer override it. (PgRefBackend’s single-tx co-commit needs the server’s shared-pool wiring, which is out of this tree; it keeps the default until that lands.)

Fail closed (heddle#354 r9, cid 3330304656). A backend with no record committer MUST NOT publish the ref batch while silently dropping the records it was handed — committed data must never be lost. A record-free publish has nothing to lose and stays on the plain path; a publish carrying records is refused with an error so the caller learns the records would have vanished, rather than discovering it after the fact via a reconcile that folds an empty tail.

Source

fn inspect_ref_summary_index(&self) -> Result<RefSummaryIndexInspection>

Source

fn rebuild_ref_summary_index(&self) -> Result<RefSummaryIndexInspection>

Source

fn pack_refs(&self) -> Result<()>

Source

fn cleanup_stale_temps(&self)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§