Help us shape the future of Go! Take the 2026 Go Developer Survey

remotesync

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package remotesync holds the pure store-side helpers for Remote Workspace sync: reading the pending push batch, applying a push response's per-commit status, reading pull state/counts, and advancing the pull cursor. It imports store + contract only. The ingest-driving pull import (which re-enters Event Intake via a runtime) lives in app, not here, so remotesync never depends upward.

Each helper exists in two forms: a LiveStore form over an ALREADY-OPEN handle (the in-process sync worker drives these through the live runtime — opening the store by path from inside the serving process would self-collide on the single-writer flock, v1.1 #2) and the original path-based form that opens/closes per call, kept for the OFFLINE CLI verbs (`sync push|pull --once`, background).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyLocalSyncPushResponse

func ApplyLocalSyncPushResponse(storePath, remoteID string, resp contract.SyncPushResponse) error

func ApplyPushResponse

func ApplyPushResponse(s LiveStore, remoteID string, resp contract.SyncPushResponse) error

ApplyPushResponse mirrors the hub's per-commit verdicts into the local sync_commits ledger (the pusher-side half of the attribution chain) through an open handle.

func ProbeAvailable

func ProbeAvailable(storePath string) error

ProbeAvailable reports whether the local store can be opened for an offline sync pass. It returns an error when a co-hosted Local Mnemon (`local run`) already holds the single-writer lock — so the standalone sync can refuse cleanly up front instead of failing every pass. It is side-effect free: a not-yet-created store is "available" (nothing holds it) without materializing the db or its dirs; an existing free store is opened and immediately released. The inverse holds too: while `local run` serves, ITS in-process worker owns sync and the offline verbs refuse here — the documented mutual exclusion between the worker and the manual verbs.

func PushBatchID

func PushBatchID(replicaID string, commits []contract.LocalCommit) string

PushBatchID derives a stable batch id from the batch content (order-independent), so a retried identical batch carries the same id — diagnostic provenance for the hub's audit, never an adjudication key (per-commit idempotency is the replay defense, sync-abi-v1 §3).

func SetPullCursor

func SetPullCursor(s LiveStore, remoteID, cursor string) error

SetPullCursor advances the durable pull cursor for remoteID through an open handle. An empty cursor is a no-op (nothing was served).

func SetSyncPullCursor

func SetSyncPullCursor(storePath, remoteID, cursor string) error

SetSyncPullCursor advances the durable pull cursor for remoteID. It is the store-side tail of the pull import; the import itself (re-entering Event Intake) lives in app.

Types

type LiveStore

type LiveStore interface {
	ReplicaID() (string, error)
	PendingSyncCommits() ([]contract.LocalCommit, error)
	MarkSyncCommitStatus(originReplicaID, localDecisionID string, ref contract.ResourceRef, status, remotePeerID, at, diagnostic string) error
	GetCursor(name string) int64
	SetCursor(name string, seq int64) error
}

LiveStore is the open-handle surface the sync passes drive: satisfied by *store.Store (the offline opener) and by *runtime.Runtime's passthroughs (the in-process worker). Cursor access is included because the pull cursor is durable sync state; callers must stay on the sync cursor names.

type LocalSyncCounts

type LocalSyncCounts struct {
	Pending   int
	Synced    int
	Conflicts int
}

func ReadLocalSyncCounts

func ReadLocalSyncCounts(storePath string) (LocalSyncCounts, error)

type LocalSyncPullState

type LocalSyncPullState struct {
	ReplicaID    string
	RemoteCursor string
}

func ReadLocalSyncPullState

func ReadLocalSyncPullState(storePath, remoteID string) (LocalSyncPullState, error)

func ReadPullState

func ReadPullState(s LiveStore, remoteID string) (LocalSyncPullState, error)

ReadPullState reads the local replica identity + the durable pull cursor for remoteID.

type LocalSyncPushBatch

type LocalSyncPushBatch struct {
	ReplicaID string
	Commits   []contract.LocalCommit
}

func ReadLocalSyncPushBatch

func ReadLocalSyncPushBatch(storePath string) (LocalSyncPushBatch, error)

func ReadPushBatch

func ReadPushBatch(s LiveStore) (LocalSyncPushBatch, error)

ReadPushBatch reads the pending outbound commits + the local replica identity from an open handle.

type RemoteEntry

type RemoteEntry struct {
	ID            string `json:"id"`
	Endpoint      string `json:"endpoint"`
	CredentialRef string `json:"credential_ref"`
	// CAFile optionally pins the remote's TLS root (PEM bundle) — the client trusts exactly it
	// (sync-abi-v1 §8). Empty = the system roots.
	CAFile string `json:"ca_file,omitempty"`
}

func LoadRemoteEntry

func LoadRemoteEntry(path, id string) (RemoteEntry, error)

LoadRemoteEntry resolves one remote from the registry at path: id "default" follows the doc's `current` pointer. It validates schema version and a non-empty endpoint; credential presence is the caller's concern (the CLI may inject a --token override).

type RemotesDoc

type RemotesDoc struct {
	SchemaVersion int           `json:"schema_version"`
	Current       string        `json:"current,omitempty"`
	Remotes       []RemoteEntry `json:"remotes"`
}

Jump to

Keyboard shortcuts

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