syncscope

package
v0.0.0-...-0b698e0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBusy = errors.New("sync scope gate unavailable")
View Source
var ErrOriginal = errors.New("original charged sync owner unavailable")

Functions

This section is empty.

Types

type Gate

type Gate struct {
	// contains filtered or unexported fields
}

Gate excludes one original-scope native writer or verifier at a time. It supplies ordering, not durable ownership or quota evidence.

func NewGate

func NewGate() *Gate

func (*Gate) BeginWrite

func (g *Gate) BeginWrite(ctx context.Context) (*Writer, error)

func (*Gate) TryVerify

func (g *Gate) TryVerify(ctx context.Context) (*Verifier, error)

type Hold

type Hold struct {
	// contains filtered or unexported fields
}

Hold keeps the original gate and sole connection across native verification. Check may be repeated after the scan; Release is idempotent.

func (*Hold) Check

func (h *Hold) Check(ctx context.Context) error

func (*Hold) Release

func (h *Hold) Release()

func (*Hold) Verifier

func (h *Hold) Verifier() *Verifier

type Identity

type Identity struct {
	Key, Side, LeaseID, Host, Owner string
}

Identity names the original in-process preparation owner. A recovered SQL row cannot supply Live, which must be the exact original owner's context.

type Original

type Original struct {
	// contains filtered or unexported fields
}

Original binds one exact live owner, the sole Manager database pool, its mutex, and the shared native gate. This object cannot be reconstructed from a row after Manager restart. It has no cleanup or final-lease authority.

func BindOriginal

func BindOriginal(ctx context.Context, db *sql.DB, managerMu *sync.Mutex, gate *Gate, live context.Context, clockRead func() (leaseclock.Sample, error), id Identity) (*Original, error)

BindOriginal is called only after the original lease and preparing row commit, under Manager's owner registration. The same lease/row is checked again on every held verification; the first read is not a cached proof.

func (*Original) HoldWriter

func (o *Original) HoldWriter(ctx context.Context, writer *Writer) (*WriterHold, error)

HoldWriter rechecks the exact current original under a fresh writer token and retains the sole SQL connection through its following native effect. The caller also rechecks held roots and native quota before the effect.

func (*Original) Record

func (o *Original) Record() Record

func (*Original) Revoke

func (o *Original) Revoke()

Revoke permanently removes in-process verification authority after an uncertain native effect. It cannot be rebuilt from the durable row.

func (*Original) TryHold

func (o *Original) TryHold(ctx context.Context) (*Hold, error)

TryHold acquires the sole SQLite connection first, then tries the native gate and Manager.mu without waiting. SQL is read through the held connection throughout the native scan, so ordinary SQLite/WAL writers cannot pass it.

type Record

type Record struct {
	Identity
	Provider, ScopeID, MountID, ProjectRootID, SelectedRootID, HomeRootID string
	EnrollmentDigest, OwnershipDigest                                     string
	ProjectID, OwnerEpoch, ChargedHard, InitialUsed, RowRevision          int64
	PreparationRevision                                                   int64
	PreparationData                                                       string
	State                                                                 string
}

Record is copied durable evidence. The mutable row state is intentionally fixed at preparing in this first bridge; it cannot authorize handoff.

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

func (*Verifier) Release

func (v *Verifier) Release()

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func (*Writer) Follows

func (w *Writer) Follows(v *Verifier) bool

Follows detects an intervening Manager writer after native verification.

func (*Writer) Release

func (w *Writer) Release()

type WriterHold

type WriterHold struct {
	// contains filtered or unexported fields
}

func (*WriterHold) Check

func (h *WriterHold) Check(ctx context.Context) error

func (*WriterHold) Release

func (h *WriterHold) Release()

Release closes the database exclusion. The caller then releases its writer gate after all native workers and any result handling have joined.

Jump to

Keyboard shortcuts

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