Skip to main content

Module remote_dispatch

Module remote_dispatch 

Source
Expand description

URL-scheme → Transport dispatch for mkit push / mkit pull.

The Rust binary wires all five shipping schemes here: mkit+file://, mkit+https:// (and mkit+http:// for local dev), mkit+s3://, and mkit+ssh://. The memory transport is in-process only, so it is reached via push_all / pull_all with an Arc<MemoryTransport> constructed in-process rather than URL-based construction. Integration tests in the mkit-cli crate exercise the memory path directly.

Credentials / environment sources:

  • HTTP(S): optional MKIT_API_TOKEN bearer.
  • S3/R2: MKIT_R2_ACCESS_KEY_ID + MKIT_R2_SECRET_ACCESS_KEY (plus optional MKIT_R2_REGION, default auto). Missing creds do NOT fail at connect time; the first signed request returns TransportError::AccessDenied.
  • SSH: spawns ssh(1) subprocess — inherits the user’s agent / keys / ~/.ssh/config. Per-repo .mkit/config SSH options (host-key checking, known-hosts path, identity file) are wired through via SshTransport::connect_with_options when config is loaded.

Enums§

DispatchError
Errors returned by the push / pull helpers. Mapped to exit codes by the commands themselves.
PushLease
CAS lease policy for a default (current-branch → upstream) push.

Functions§

fetch_all
fetchpull_all without the HEAD update. Downloads every object reachable from each remote ref (via Transport::download_pack on the object’s own digest) and writes the ref into refs/remotes/default/<branch>.
lease_condition
Resolve the CAS condition for a single-branch push from the local remote-tracking ref refs/remotes/<remote>/<branch> and the lease policy.
open
Open a transport for the given URL. Returns a type-erased Arc so callers can treat all schemes uniformly.
open_trusted
Open a transport for endpoint only after the per-endpoint credential-trust gate (#97) approves it.
pull_all
Fetch remote refs, then fast-forward the current local branch from refs/remotes/default/<branch>. Fresh repos with no local branch tip initialise from the current branch’s remote-tracking ref, or the first advertised remote branch when the current default branch is absent.
push_all
Push every ref under refs/heads/ to the remote, assembling a pack of every object reachable from the branch tip that the remote does not already hold. Returns the count of refs pushed.
push_all_with
CAS-aware mirror push (mkit push --all). Pushes every local refs/heads/* to the remote, using the remote-tracking ref under refs/remotes/<remote>/<branch> as the CAS lease (Missing when no tracking ref exists, Match otherwise). force upgrades every write to an unconditional Any. On success each pushed branch’s remote-tracking ref is advanced to the pushed tip.
push_branch
Push one branch: upload every object reachable from tip that the remote lacks, then CAS-write refs/heads/<branch> under condition.
push_branch_tracked
Push the current branch to its upstream and, on success, advance the local remote-tracking ref refs/remotes/<remote>/<branch> to the pushed tip.