Documentation
¶
Overview ¶
Package items is the items ledger: the only writer of a unit's items.
Index ¶
- Constants
- Variables
- func DedupeKey(o items.Op) string
- type Applied
- type Applier
- type Commit
- type DisabledError
- type Ledger
- func (l *Ledger) Apply(ctx context.Context, prov items.Provenance, ops []items.Op) (Result, error)
- func (l *Ledger) Decide(ctx context.Context, id int64, accept bool) (Result, error)
- func (l *Ledger) Items(ctx context.Context, u unit.Unit) ([]items.Item, error)
- func (l *Ledger) Proposals(ctx context.Context, state ProposalState) ([]Proposal, error)
- func (l *Ledger) Query(ctx context.Context, q Query) ([]items.Item, error)
- func (l *Ledger) Reconcile(ctx context.Context, u unit.Unit, desired []items.Item, at unit.Anchor, ...) (Result, error)
- type LogEntry
- type Proposal
- type ProposalState
- type Query
- type Reader
- type Reconciler
- type Refused
- type Result
- type Store
Constants ¶
const ( OutcomeApplied = "applied" OutcomeNoop = "noop" OutcomeProposed = "proposed" OutcomeRefused = "refused" )
Outcomes of an op in the log.
const ExtractedLinkLookback = 7 * 24 * time.Hour
ExtractedLinkLookback is how far before its item's creation an extracted link may start: the extractor's window holds older messages, as far back as the Slack backfill.
Variables ¶
var ErrNoProposal = errors.New("no open proposal")
ErrNoProposal is Decide's error for an id that names no open proposal.
Functions ¶
Types ¶
type DisabledError ¶
type DisabledError struct{ Provider unit.ProviderID }
DisabledError is returned, with nothing applied, when an op or a proposal names a unit of a disabled plugin; the daemon answers it with 409.
func (*DisabledError) Error ¶
func (e *DisabledError) Error() string
type Ledger ¶
type Ledger struct {
Store Store
Links port.LinkStore // nil refuses link ops
Enabled func(unit.ProviderID) bool // nil: every provider enabled
Clock port.Clock
Log func(string, ...any)
// contains filtered or unexported fields
}
Ledger serializes Apply, Reconcile and Decide; a process keeps one Ledger per store.
func (*Ledger) Apply ¶
Apply applies ops in order, each applied, proposed, refused or a no-op, and commits the outcome of the batch at once.
func (*Ledger) Reconcile ¶
func (l *Ledger) Reconcile(ctx context.Context, u unit.Unit, desired []items.Item, at unit.Anchor, absent items.Resolution) (Result, error)
Reconcile makes the derived items of u equal desired: create or update each, and resolve an open derived item absent from desired with Resolution absent (superseded when "") and evidence {unit_event, at}. Desired items carry their final State and Resolution. A derived change to a confirmed item is logged noop with reason "confirmed" and never proposed. Reconcile on a disabled provider returns DisabledError and writes nothing.
type ProposalState ¶
type ProposalState string // "open", "accepted", "rejected"
const ( ProposalOpen ProposalState = "open" ProposalAccepted ProposalState = "accepted" ProposalRejected ProposalState = "rejected" )
type Reader ¶
type Reader interface {
Load(ctx context.Context, units []unit.Unit) (map[unit.Unit][]items.Item, error)
Query(ctx context.Context, q Query) ([]items.Item, error)
Proposals(ctx context.Context, state ProposalState) ([]Proposal, error)
Log(ctx context.Context, u unit.Unit, since time.Time) ([]LogEntry, error) // op outcomes, for history
}
Reader is the read half of Store.