Weave documentation
Rust referenceloom-gateway

loom-gateway · worker

Source declarations, signatures and documentation for worker.

Source: sigil/weave/tools/loom-gateway/src/worker.rs. SHA-256: 3c28ec6fd309e15eb2bd5356aeb09b7d61b7e1c1b8ca12bbc4b85294ce161e3e.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

worker::CHANNEL_CAP

Capacity of the request channel. 256 is generous for a local developer-facing gateway; we surface backpressure via 503.

pub const CHANNEL_CAP: usize;

Source line: 25.

worker::WorkerRequest

One unit of work the gateway can ask of the WeaveNode.

pub enum WorkerRequest {
    /// `GET /api/v1/repos`
    ListRepos {
        reply: oneshot::Sender<Result<Vec<RegistryEntry>, ApiError>>,
    },
    /// `GET /api/v1/repos/:name`
    GetRepo {
        name: String,
        reply: oneshot::Sender<Result<RegistryEntry, ApiError>>,
    },
    /// `GET /api/v1/repos/:name/commits` — log walk.
    LogCommits {
        repo_name: String,
        branch: String,
        limit: usize,
        reply: oneshot::Sender<Result<LogResult, ApiError>>,
    },
    /// `GET /api/v1/repos/:name/commits/:rev`
    GetCommit {
        repo_name: String,
        rev: String,
        reply: oneshot::Sender<Result<(u64, LoomCommit), ApiError>>,
    },
    /// `GET /api/v1/repos/:name/tree/:rev[/*path]`
    ReadTreeAt {
        repo_name: String,
        rev: String,
        reply: oneshot::Sender<Result<TreeManifest, ApiError>>,
    },
    /// `GET /api/v1/repos/:name/blob/:hash`
    ReadBlob {
        repo_name: String,
        hash: String,
        reply: oneshot::Sender<Result<Vec<u8>, ApiError>>,
    },
    /// Discard the cached user-wide WeaveNode and re-open it on the next
    /// registry call. Sent by the clone handler after register completes
    /// — without this, the long-running gateway can't see new entries
    /// written by sibling subprocesses.
    ReloadRegistry {
        reply: oneshot::Sender<Result<(), ApiError>>,
    },
    /// `GET /api/v1/repos/:name/pulls`
    ListPrs {
        repo_name: String,
        reply: oneshot::Sender<Result<Vec<loom_pr::Pr>, ApiError>>,
    },
    /// `GET /api/v1/repos/:name/pulls/:id` — PR + approvals.
    GetPr {
        repo_name: String,
        pr_id: String,
        reply: oneshot::Sender<Result<(loom_pr::Pr, Vec<loom_pr::Approval>), ApiError>>,
    },
    /// Drop a per-repo cached node. Sent by handlers after a PR is
    /// approved/merged so the next read sees the latest lens state.
    ReloadRepo {
        repo_name: String,
        reply: oneshot::Sender<Result<(), ApiError>>,
    },
    /// `GET /api/v1/repos/:name/branches`
    ListBranches {
        repo_name: String,
        reply: oneshot::Sender<Result<Vec<BranchInfo>, ApiError>>,
    },
    /// `GET /api/v1/repos/:name/mandates` — every mandate scoped to this
    /// repo's repo_id, plus revocations.
    ListMandates {
        repo_id: String,
        reply: MandatesReply,
    },
    /// `GET /api/v1/repos/:name/mars/:did` — single MARS anchor lookup.
    GetMarsAnchor {
        did: String,
        reply: oneshot::Sender<Result<Option<loom_mars::MarsAnchor>, ApiError>>,
    },
    /// Match any anchor whose `payload.repo_id` equals the requested
    /// repo_id. Used by the settings page so we don't need to know the
    /// owner's handle to find their anchor for a given repo.
    GetMarsAnchorByRepoId {
        repo_id: String,
        reply: oneshot::Sender<Result<Option<loom_mars::MarsAnchor>, ApiError>>,
    },
}

Source line: 37.

worker::BranchInfo

Wire shape: a single branch with its current tip.

#[derive(Clone, Debug, Serialize)]
pub struct BranchInfo {
pub name: String,
pub tip_seq: u64,
pub tip_id: String,
pub tip_author: String,
pub tip_message: String,
pub tip_timestamp_ms: u64
}

Source line: 123.

worker::LogResult

#[derive(Clone, Serialize)]
pub struct LogResult {
pub head_seq: Option<u64>,
pub commits: Vec<(u64, LoomCommit)>
}

Source line: 133.

worker::LoomCommit

Mirror of loom's commit object so we can decode it without taking a circular dep. Layout is stable per tools/loom/src/manifest.rs.

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct LoomCommit {
pub version: u32,
pub tree: TreeManifest,
pub tree_id: String,
pub parents: Vec<u64>,
pub author: String,
pub timestamp_ms: u64,
pub message: String
}

Source line: 141.

worker::TreeManifest

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TreeManifest {
pub entries: Vec<ManifestEntry>
}

Source line: 152.

worker::ManifestEntry

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ManifestEntry {
pub path: String,
pub blob: String,
pub mode: FileMode,
pub size: u64
}

Source line: 157.

worker::FileMode

#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FileMode {
    Regular,
    Executable,
    Symlink,
}

Source line: 165.

worker::spawn

Spawn the worker on a dedicated OS thread running a current-thread tokio runtime. Returns the Sender handlers should use, plus the thread join handle (caller should keep this alive for the lifetime of the gateway).

pub fn spawn(workdir: PathBuf) -> std::io::Result<(mpsc::Sender<WorkerRequest>, JoinHandle<()>)>;

Source line: 179.

On this page