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
- Variables
- type Intent
- type PullOptions
- type PullResult
- type Status
- type Store
- func (s *Store) Bind(ctx context.Context, c *client.Client) (protocol.Identity, error)
- func (s *Store) Close() error
- func (s *Store) Enqueue(ctx context.Context, r protocol.PublishRequest) (Intent, error)
- func (s *Store) Get(ctx context.Context, key string) (protocol.Artifact, error)
- func (s *Store) Intent(ctx context.Context, id string) (Intent, error)
- func (s *Store) Pull(ctx context.Context, c *client.Client, options PullOptions) (PullResult, error)
- func (s *Store) Push(ctx context.Context, c *client.Client, id string) (Intent, error)
- func (s *Store) ResetPull(ctx context.Context) error
- func (s *Store) Resolve(ctx context.Context, id, decision string) error
- func (s *Store) Status(ctx context.Context) (Status, error)
Constants ¶
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 ¶
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 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 ¶
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 ¶
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) Enqueue ¶
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) 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 ¶
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 ¶
ResetPull explicitly starts a fresh staged snapshot, retaining the prior complete cache until promotion. It never changes intents or upstream state.