meshclient

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package meshclient is the Mesh team-sync client: the low-level RPC transport to a mesh-hub plus the high-level vault orchestration (join + reconcile) that reads and writes a vault's local sync state. It never runs git; it speaks the pull-based reconcile protocol over HTTPS. cmd/mesh drives it, and the future TUI RemoteBackend will reuse it.

Index

Constants

This section is empty.

Variables

View Source
var Logf = func(string, ...any) {}

Logf is an optional sink for non-fatal StreamEvents diagnostics (e.g. an auth-class rejection). Defaults to a no-op so the library stays quiet unless a caller (cmd/mesh) wires in a logger.

Functions

func StreamEvents

func StreamEvents(ctx context.Context, vaultDir string, nudge chan<- struct{}) error

StreamEvents subscribes to the hub's SSE nudge stream for a joined vault and sends a (non-blocking) signal on nudge for every "head changed" event. It reconnects until ctx is cancelled, so a dropped stream self-heals. The nudge is stateless: the caller just runs a reconcile, so a missed or coalesced event is harmless (the periodic reconcile is the safety net). StreamEvents returns nil on ctx cancellation; it returns an error only if the vault is not joined (no credentials). A server-side rejection is not fatal here: an auth-class status (401/403/410) may be transient during a hub restart, so it backs off longer and logs rather than giving up, while the caller's periodic reconcile keeps the vault converging regardless.

Types

type Client

type Client struct {
	HubURL string
	Token  string
	HTTP   *http.Client
}

Client is the HTTP transport to one hub.

func ClientForVault

func ClientForVault(vaultDir string) (*Client, error)

ClientForVault builds an authed transport from a joined vault's stored credentials (.mesh/credentials). Used by the mesh-curator to call the hub's curation endpoints with the same token it syncs with.

func New

func New(hubURL, token string) *Client

New builds a client for a hub base URL and (optional) bearer token.

func (*Client) CurationActivity

func (c *Client) CurationActivity(limit int) ([]syncproto.CurationJob, error)

CurationActivity lists the hub's recent terminal curation jobs (resolved + failed), most-recent first, for the team-wide "what did the curator do" view. limit <= 0 uses the hub default.

func (*Client) CurationJob

func (c *Client) CurationJob(id int64) (syncproto.CurationJob, error)

CurationJob fetches one job including its IncomingB64 (the losing version).

func (*Client) CurationJobs

func (c *Client) CurationJobs() ([]syncproto.CurationJob, error)

CurationJobs lists the hub's pending curation markers (metadata only).

func (*Client) FailCuration

func (c *Client) FailCuration(id int64, reason string) error

FailCuration charges a failed attempt against a job; the hub marks it terminal at the attempt cap so a job the agent cannot satisfy stops being retried.

func (*Client) Join

func (c *Client) Join(invite string) (syncproto.JoinResponse, error)

Join redeems a one-time invite for a client token (no bearer needed).

func (*Client) ResolveCuration

func (c *Client) ResolveCuration(id int64, resolvedHead string) error

ResolveCuration marks a job resolved, recording the HEAD the merge landed at.

func (*Client) Sync

Sync runs one reconcile round (authed).

func (*Client) Vault

func (c *Client) Vault() (syncproto.VaultInfo, error)

Vault fetches vault metadata (authed).

type Summary

type Summary struct {
	Pushed           int
	Pulled           int
	Conflicts        int
	Head             string
	ConflictSiblings []string // merge conflicts: our pushed version parked here
	Protected        []string // external-editor race: incoming hub version parked here
	Dropped          []string // full-reconcile: locals removed because deleted upstream
	Rejected         []string // hub refused these (viewer/ACL/scope/oversize); kept dirty to retry
}

Summary reports what a sync round did, for the CLI.

func JoinVault

func JoinVault(hubURL, invite, vaultDir string) (Summary, error)

JoinVault redeems an invite, stores credentials, verifies embedding homogeneity against the hub-authoritative mesh.toml, and clones the vault via a reconcile from an empty base.

func SyncVault

func SyncVault(vaultDir string) (Summary, error)

SyncVault runs one reconcile round against the joined hub: push local edits, apply the hub's deltas, and persist the new base. It does not reindex; the caller (cmd/mesh) runs index.Reconcile afterward.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL