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

edge

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package edge is a bounded durable outbox and read cache for one authoritative Questlock broker. It never accepts peer journals or invents upstream versions.

Index

Constants

View Source
const (
	MaxIntents     = 128
	MaxOutboxBytes = 64 << 20 // reservations include both request and eventual receipt
	MaxCacheItems  = 4096
	MaxCacheBytes  = 32 << 20 // independently bounds visible and staging snapshots
	MaxFileBytes   = 256 << 20
)

Variables

View Source
var (
	ErrBusy      = errors.New("edge is already open or has an active operation")
	ErrIdentity  = errors.New("upstream authority, scope or agent differs from the pinned identity")
	ErrUnbound   = errors.New("bind the edge to an authenticated upstream identity first")
	ErrUncertain = errors.New("publish is uncertain; retain and explicitly retry the exact intent")
	ErrBlocked   = errors.New("intent is blocked; explicitly resolve it without changing its request")
	ErrLimit     = errors.New("edge storage quota exceeded; checkpoint and request are unchanged")
	ErrNotReady  = errors.New("no complete authoritative snapshot is available")
)

Functions

This section is empty.

Types

type Intent

type Intent struct {
	Request        protocol.PublishRequest `json:"request"`
	State          string                  `json:"state"`
	Receipt        *protocol.PublishResult `json:"receipt,omitempty"`
	Code           string                  `json:"code,omitempty"`
	CurrentVersion int64                   `json:"current_version,omitempty"`
}

type PullOptions

type PullOptions struct{ Limit, MaxBytes int }

type PullResult

type PullResult struct {
	Kind    string `json:"kind"`
	Applied int    `json:"applied"`
	HasMore bool   `json:"has_more"`
	Through int64  `json:"through"`
}

type Status

type Status struct {
	Identity            protocol.Identity `json:"identity"`
	SnapshotComplete    bool              `json:"snapshot_complete"`
	SnapshotInProgress  bool              `json:"snapshot_in_progress"`
	Through             int64             `json:"through"`
	CacheItems          int               `json:"cache_items"`
	PendingBytes        int64             `json:"pending_bytes"` // encoded requests, not resident memory
	OutboxReservedBytes int64             `json:"outbox_reserved_bytes"`
	Intents             map[string]int    `json:"intents"`
}

type Store

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

func Open

func Open(directory string) (*Store, error)

Open owns one private edge directory for its lifetime. The directory is not the upstream server database and must never be shared by independent edges.

func (*Store) Bind

func (s *Store) Bind(ctx context.Context, c *client.Client) (protocol.Identity, error)

Bind explicitly trusts the first authenticated identity and persists it. A later bind can only confirm the same authority, scope and receipt agent.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Enqueue

func (s *Store) Enqueue(ctx context.Context, r protocol.PublishRequest) (Intent, error)

Enqueue commits the complete immutable request before any publish can occur. Reusing an operation ID with another body is refused, even after abandonment.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) (protocol.Artifact, error)

func (*Store) Intent

func (s *Store) Intent(ctx context.Context, id string) (Intent, error)

func (*Store) Pull

func (s *Store) Pull(ctx context.Context, c *client.Client, options PullOptions) (PullResult, error)

Pull fetches exactly one page from the persisted checkpoint. A snapshot stays private in staging until complete; page data and its checkpoint commit in one SQLite transaction. Failed validation or quota checks retain the old cursor.

func (*Store) Push

func (s *Store) Push(ctx context.Context, c *client.Client, id string) (Intent, error)

Push makes exactly one attempt of this persisted request. An uncertain intent is an explicit retry of the same operation ID/body; it never rebases a version. Accepted receipts never update the read cache: replay may return an old head.

func (*Store) ResetPull

func (s *Store) ResetPull(ctx context.Context) error

ResetPull explicitly starts a fresh staged snapshot, retaining the prior complete cache until promotion. It never changes intents or upstream state.

func (*Store) Resolve

func (s *Store) Resolve(ctx context.Context, id, decision string) error

Resolve is an explicit caller decision for a known conflict (retry the same bytes or abandon), or abandonment of an unsent queued intent. Uncertain work cannot be abandoned because the authority may already have accepted it.

func (*Store) Status

func (s *Store) Status(ctx context.Context) (Status, error)

Jump to

Keyboard shortcuts

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