Documentation
¶
Overview ¶
Package outbox keeps the drafts the loop proposes and delivers them. Each draft waits on a draft gate, which holds the decision: the outbox posts a draft only once its gate approved it.
Index ¶
- Constants
- Variables
- func EvidenceOps(d draft.Draft) []items.Op
- type Amendment
- type AppliedStore
- type Applier
- type Bases
- type Caller
- type Effect
- type EffectApplier
- type EffectLookup
- type EffectRunner
- type Effects
- type Evidence
- type Facts
- type Filter
- type Gates
- type Implementer
- type Kinds
- type Manifests
- type Pending
- type Policies
- type Proposal
- type QuestionPins
- type Recent
- type RecentBases
- type Resolver
- type Results
- type Service
- func (s *Service) Adopt(ctx context.Context, ended func(ctx context.Context, id task.ID) (bool, error)) (adopted, withdrawn int, err error)
- func (s *Service) AgentAmend(ctx context.Context, c Caller, id draft.ID, a Amendment) (draft.Draft, error)
- func (s *Service) AgentRead(ctx context.Context, c Caller, id draft.ID) (draft.Draft, []draft.Revision, error)
- func (s *Service) AgentWithdraw(ctx context.Context, c Caller, id draft.ID, rev int64, reason string) (draft.Draft, error)
- func (s *Service) Amend(ctx context.Context, id draft.ID, a Amendment) (draft.Draft, error)
- func (s *Service) ApplyPending(ctx context.Context) error
- func (s *Service) ApplySilently(ctx context.Context, u unit.Unit, effects []string) error
- func (s *Service) BroadcastOf(ctx context.Context, p Proposal) (draft.Broadcast, error)
- func (s *Service) CloseSilently(ctx context.Context, id draft.ID) (draft.Draft, error)
- func (s *Service) DeliveryOf(ctx context.Context, g gate.Gate) (draft.State, error)
- func (s *Service) Discard(ctx context.Context, id draft.ID, reason string) (draft.Draft, error)
- func (s *Service) Edit(ctx context.Context, id draft.ID, text string, rev int64) (draft.Draft, error)
- func (s *Service) Ended(ctx context.Context, id task.ID, keep []string) ([]draft.Draft, error)
- func (s *Service) GateOf(ctx context.Context, d draft.Draft) (gate.Gate, bool, error)
- func (s *Service) GatesOf(ctx context.Context, ds []draft.Draft) (map[draft.ID]gate.Gate, error)
- func (s *Service) KindOf(d draft.Draft) (draft.KindSpec, bool)
- func (s *Service) List(ctx context.Context, f Filter) ([]draft.Draft, error)
- func (s *Service) Outbox(ctx context.Context) ([]Pending, error)
- func (s *Service) PlaceBroadcasts(ctx context.Context) error
- func (s *Service) Prepare(ctx context.Context, id draft.ID, rev int64) (draft.Draft, error)
- func (s *Service) Propose(ctx context.Context, p Proposal) (draft.Draft, error)
- func (s *Service) Publish(ctx context.Context, g gate.Gate) error
- func (s *Service) PublisherOf(d draft.Draft) unit.ProviderID
- func (s *Service) Reask(ctx context.Context) error
- func (s *Service) Recover(ctx context.Context) error
- func (s *Service) Rehomed(ctx context.Context, units ...unit.Unit) error
- func (s *Service) Retry(ctx context.Context, id draft.ID, confirm bool) (draft.Draft, error)
- func (s *Service) RetryBy(ctx context.Context, id draft.ID, confirm bool, by draft.Actor) (draft.Draft, error)
- func (s *Service) Revisions(ctx context.Context, id draft.ID) ([]draft.Revision, error)
- func (s *Service) Send(ctx context.Context) (sent, failed int, err error)
- func (s *Service) SetBroadcast(ctx context.Context, id draft.ID, on bool, rev int64) (draft.Draft, error)
- func (s *Service) SilentlyApplicable(p unit.ProviderID, effects []string) error
- func (s *Service) Stale(ctx context.Context, d draft.Draft) (bool, error)
- func (s *Service) Staleness(ctx context.Context, d draft.Draft) (stale, known bool)
- func (s *Service) Withdraw(ctx context.Context, id draft.ID, reason string) (draft.Draft, error)
- func (s *Service) WithdrawHeld(ctx context.Context, id draft.ID, reason string) (draft.Draft, error)
- type SettledReader
- type Store
- type TaskPlacer
Constants ¶
const NotConfirmed = "not confirmed after a restart"
NotConfirmed is the Error of a draft Recover found in sending and Verify could not confirm.
Variables ¶
var ( ErrNotFound = errors.New("no such draft") ErrConflict = errors.New("the draft changed state") ErrDisabled = errors.New("the draft's plugin is disabled or has no publisher") ErrDuplicate = errors.New("an open draft of the same rule and key exists") ErrNeedsConfirm = errors.New("the draft may have been posted; retry needs confirm") ErrInvalid = errors.New("invalid draft") ErrNoGates = errors.New("the outbox has no gates to hold its drafts") // ErrNoBases: a draft states a basis and nothing reads the live one. ErrNoBases = errors.New("nothing reads a live basis") // ErrStale: the unit moved past the basis the draft was written against. ErrStale = errors.New("the draft is stale: the unit changed since it was written") // ErrRevConflict: the draft is at another rev than the one its reviser read; it is also an ErrConflict. ErrRevConflict = fmt.Errorf("the draft changed since it was read: %w", ErrConflict) // ErrOutOfScope: the draft is not the calling agent's to change. ErrOutOfScope = errors.New("the draft is out of the caller's reach") )
var ErrUnknownEffect = errors.New("no implementation of the effect")
ErrUnknownEffect is an effect a draft declares that has no implementation for its provider.
var ErrUnknownOrigin = errors.New("unknown proposer")
ErrUnknownOrigin is a draft's proposing intent, workflow or turn that the manifests or the book do not know.
Functions ¶
Types ¶
type Amendment ¶ added in v0.4.0
type Amendment struct {
Text *string
Broadcast *bool
Payload *json.RawMessage
// Basis is what the reviser read the unit at, checked live as a proposal's.
Basis *string
// Rev is the rev the reviser read, at least 1: a draft at another is ErrRevConflict.
Rev int64
// By is who revises it; zero is a person. AgentAmend sets it from its Caller.
By draft.Actor
}
Amendment is what a person or an agent changes on a draft: its text, a thread reply's broadcast, its payload, its basis, or several; nil leaves it.
type AppliedStore ¶ added in v0.2.0
type AppliedStore interface {
// Unapplied are the drafts whose effects are due (draft.EffectsDue),
// that declare effects and whose EffectsAppliedAt is zero, oldest first.
Unapplied(ctx context.Context) ([]draft.Draft, error)
// MarkApplied stores at as the draft's EffectsAppliedAt.
MarkApplied(ctx context.Context, id draft.ID, at time.Time) error
}
AppliedStore keeps when a sent draft's effects were applied.
type Applier ¶ added in v0.2.0
type Applier interface {
Apply(ctx context.Context, d draft.Draft) error
// Pending are the sent drafts whose effects are not applied yet.
Pending(ctx context.Context) ([]draft.Draft, error)
}
Applier applies the Effects of a sent draft exactly once: each by its name, then the draft's EffectsAppliedAt, so a restart applies only those of drafts sent and not yet applied.
type Bases ¶ added in v0.5.0
type Bases interface {
// Live is what a draft of kind on u, which publisher posts (Service.PublisherOf), would be written
// against now, such as a pull request's head; publisher's manifest declares kind.
Live(ctx context.Context, publisher unit.ProviderID, u unit.Unit, kind string) (string, error)
}
Bases read the live basis of a unit, never a cached one.
type Caller ¶ added in v0.5.0
Caller is the agent session an agent's call on a draft comes from, and the units its turns are on.
type EffectApplier ¶ added in v0.2.0
type EffectApplier struct {
Store AppliedStore
Effects EffectLookup
Clock port.Clock
}
EffectApplier is the Applier over a store and the effect implementations.
func (EffectApplier) Apply ¶ added in v0.2.0
Apply runs every effect d declares, in order, then marks d applied; a draft whose effects are not due (draft.EffectsDue), or already applied, is left as it is. When an effect fails nothing is marked, so the next Pending pass runs them all again: each effect is idempotent.
func (EffectApplier) Implements ¶ added in v0.2.0
func (a EffectApplier) Implements(p unit.ProviderID, name string) bool
type EffectLookup ¶ added in v0.2.0
type EffectLookup func(p unit.ProviderID, name string) (Effect, bool)
EffectLookup is the implementation of effect name for drafts of provider p; false when there is none.
type EffectRunner ¶ added in v0.6.0
EffectRunner is an optional capability of an Applier: it runs the effects d declares with no record of them.
type Effects ¶
type Effects func(p unit.ProviderID) (port.Effects, error)
Effects returns the publishing capability of a provider; an error wrapping ErrDisabled when its plugin is off or has no publisher.
type Evidence ¶
Evidence receives a sent draft's evidence for its items (wired to the items ledger, op "evidence").
func EvidenceTo ¶
func EvidenceTo(apply func(ctx context.Context, prov items.Provenance, ops []items.Op) error) Evidence
EvidenceTo is an Evidence that applies a sent draft's EvidenceOps through apply, with provenance effects.
type Facts ¶ added in v0.2.0
Facts reads the facts of unit u that a policy's rules read, scoped by workflow when it is set.
type Gates ¶ added in v0.3.0
type Gates interface {
Open(ctx context.Context, g gate.Gate, p gates.Policy) (gate.Gate, error)
Supersede(ctx context.Context, id int64, by task.Actor) error
// SupersedeForAgent closes open draft gate id because session revised its draft.
SupersedeForAgent(ctx context.Context, id int64, session string) (gate.Gate, error)
Where(ctx context.Context, q gates.Query) ([]gate.Gate, error)
}
Gates holds the decision each draft waits on: a draft gate whose Subject is the draft's ID. Its resolution reaches the outbox through Publish.
type Implementer ¶ added in v0.2.0
type Implementer interface {
Applier
Implements(p unit.ProviderID, name string) bool
}
Implementer is an Applier that says whether it has effect name for the drafts of provider p, so Propose refuses a draft it could never apply.
type Kinds ¶ added in v0.5.0
type Kinds interface {
// Lookup is the kind name of provider, the provider of the draft's publisher (Service.PublisherOf),
// never of its unit; false when its manifest declares none. Lookup and Validate run only on propose
// and amend, never on send, show or Recover, so a stored draft keeps its stored delivery.
Lookup(provider, kind string) (draft.KindSpec, bool)
// Shape is d with its kind, purpose and delivery as provider's manifest declares them (draft.Catalog's
// Shape): a kind provider does not declare is refused, and a provider that declares none leaves d as it
// is.
Shape(provider string, d draft.Draft) (draft.Draft, error)
// Validate refuses a payload that does not fit spec's schema, wrapping ErrInvalid.
Validate(spec draft.KindSpec, payload json.RawMessage) error
}
Kinds are the draft kinds the plugins' manifests declare.
type Manifests ¶
type Manifests interface {
// DefaultApproval is gates.toml's default for a draft gate, which a
// draft no manifest's block decides takes.
DefaultApproval() draft.Approval
// IntentApproval is the block of intent name, nil when it declares none; known is false for an unknown intent.
IntentApproval(name string) (p *draft.Policy, known bool)
// WorkflowApproval is the policy of the drafts of a turn workflow name
// started, of an intent whose block is intent: the workflow's block, else
// intent, with what the configuration lays over it; nil when none
// applies. known is false for an unknown workflow.
WorkflowApproval(name string, intent *draft.Policy) (p *draft.Policy, known bool)
// Turn is the intent of turn seq in u's book and the workflow that started it; ok is false when the book has no such turn.
Turn(ctx context.Context, u unit.Unit, seq int64) (intent, workflow string, ok bool, err error)
}
Manifests reads the [gates.approval] of the loaded intents and workflows for their draft gates, the profile's default for one, and the turns book.
type Policies ¶
type Policies interface {
For(ctx context.Context, u unit.Unit, o draft.Origin) (draft.Policy, error)
}
Policies resolves the approval policy of a proposal on u whose Policy is nil.
type Proposal ¶
type Proposal struct {
Unit unit.Unit
Items []string
Task string
Kind draft.Kind
Target, Text, Reaction string
// Broadcast is the broadcast the proposer asks for a thread reply; its
// publisher's Placer decides the draft's.
Broadcast draft.Broadcast
// Replaced is the text an edit replaces.
Replaced string
Origin draft.Origin
// Policy is the draft's approval policy; nil: resolved by
// Service.Policies from Origin.
Policy *draft.Policy
// Subject is the subject the proposer read, whose facts the policy's
// rules read; nil: Service.Facts reads the unit's.
Subject *draft.Subject
// Purpose and Delivery are the draft's shape. A Kind its publisher's
// manifest declares gives the Delivery; with no Kind, a Purpose that names
// a declared kind is that kind, and any other takes the kind of Delivery.
Purpose string
Delivery draft.Delivery
// Effects are applied once the draft is sent, names of builtin.Effects.
Effects []string
// RepeatAfter is how long a settled draft of the same origin holds this
// proposal from being proposed again; zero keeps Service.RepeatAfter.
RepeatAfter time.Duration
// Why is why the draft is proposed, in the user's language; Language
// is the locale Text is written in.
Why, Language string
// Payload is what the kind's schema shapes beside Text; nil for none.
Payload json.RawMessage
// Basis is what the proposer read the unit at, checked against the live
// value for a kind whose basis the agent states.
Basis string
// Hold keeps the draft waiting for a person whatever its approval
// rules say, except under dry_run.
Hold bool
}
type QuestionPins ¶ added in v0.5.0
QuestionPins is optional on Gates: Decides refuses, with an error wrapping gates.ErrRefused, a retry of the draft of drafted gate drafted that a question decides, one it pins and its answer has not picked.
type Recent ¶ added in v0.5.0
type Recent interface {
Recent(ctx context.Context, publisher unit.ProviderID, u unit.Unit, kind string) (string, error)
}
Recent is optional: Bases that also serve a read of a unit's basis made a while ago, to a reader that takes one, as Staleness does for a draft's card. Live still reads now.
type RecentBases ¶ added in v0.5.0
type RecentBases struct {
Bases Bases
Clock port.Clock
// Fresh is how long a read serves; ReadTimeout bounds one read.
Fresh, ReadTimeout time.Duration
// Reads runs the reads that outlive their caller; its owner waits on it before what Bases reach goes away.
// Nil reads in the caller.
Reads *sync.WaitGroup
// Log reports a read that failed for another reason than a deadline; nil reports none.
Log func(format string, args ...any)
// contains filtered or unexported fields
}
RecentBases are Bases whose Recent shares one read per publisher, unit and kind among every caller within Fresh: the read in flight, else the last one while it is fresh, else a new one. A read runs past the caller that started it, bounded by ReadTimeout, so the next caller finds its answer; a caller waits for it only until its own context ends.
type Resolver ¶
type Resolver struct {
Manifests Manifests
}
Resolver is the Policies of the manifests, for turn and session drafts only: the proposing turn's workflow's policy laid over its intent's block, else the profile's default. The intent and workflow come from the turn in the book; an Origin that names others than the book's resolves to wait. Every other origin resolves to wait, so a rule's policy reaches a draft only through Proposal.Policy.
type Results ¶ added in v0.3.0
type Results interface {
// AttachesPosts says whether the turns of intent attach their posts.
AttachesPosts(intent string) bool
Attach(ctx context.Context, tk task.ID, u unit.Unit) error
}
Results attaches to a task the unit of each post a turn on it makes.
type Service ¶
type Service struct {
Store Store
// Gates holds the gate each draft waits on.
Gates Gates
Effects Effects
// Targets are the providers whose publishers PublisherOf asks to take a
// draft's target.
Targets []unit.ProviderID
Policies Policies // nil resolves every proposal to wait
// Posts says whether a draft of a delivery reaches people, as the
// plugins' manifests declare it, so a policy releases one only by a rule
// that names that delivery; nil: every delivery does.
Posts func(d draft.Delivery) bool
Facts Facts // nil: a policy whose rules read the unit's facts resolves to wait
// Broken names the workflows that failed to load; a draft of one whose
// gate a rule or a window released fails, for a person to retry, until
// it loads again.
Broken func() []string
Evidence Evidence // nil none
Changes port.Changes
Clock port.Clock
Log func(format string, args ...any) // ids, states and kinds only; never text or tokens
// OnSent runs after a draft is stored as sent and its Evidence call (last-nudge stamps, plugin bookkeeping).
OnSent []func(ctx context.Context, d draft.Draft) error
// RepeatAfter is how long a dry_run draft keeps an auto proposal of its key from being stored again;
// zero keeps it for good.
RepeatAfter time.Duration
// Applier applies a sent draft's Effects; nil applies none.
Applier Applier
// Results attaches a sent post to its turn's task; nil attaches none.
Results Results
// Silent says whether effect name applies without its draft's post, so CloseSilently may apply it; nil:
// none does.
Silent func(name string) bool
// Kinds are the manifests' draft kinds, the only source of a kind's delivery; nil declares none, so a draft
// keeps the kind, purpose and delivery its proposer gave.
Kinds Kinds
// Bases read the live basis of a draft whose kind's basis the agent states; with nil, such a draft is
// refused, never passed.
Bases Bases
}
func (*Service) Adopt ¶ added in v0.4.0
func (s *Service) Adopt(ctx context.Context, ended func(ctx context.Context, id task.ID) (bool, error)) (adopted, withdrawn int, err error)
Adopt gives each held draft of no task the task its open gate waits on, and withdraws, as draft.WithdrawEnded, one whose task ended says has ended; a draft whose gate is on no task stays as it is.
func (*Service) AgentAmend ¶ added in v0.5.0
func (s *Service) AgentAmend(ctx context.Context, c Caller, id draft.ID, a Amendment) (draft.Draft, error)
AgentAmend applies a to held or failed draft id for c, at a.Rev, stamping a.By from c: a rev below 1 is ErrInvalid, a draft of another rev ErrRevConflict, one that is not of turn or session origin, or neither on nor proposed from c's units, ErrOutOfScope. The revision supersedes the draft's gate and opens a waiting one that stamps c.Session; a failed draft goes back to held.
func (*Service) AgentRead ¶ added in v0.5.0
func (s *Service) AgentRead(ctx context.Context, c Caller, id draft.ID) (draft.Draft, []draft.Revision, error)
AgentRead is draft id, with the delivery its kind posts as now, and its revisions, for c: a draft on, or proposed from, one of c's units. A draft out of c's reach is ErrOutOfScope.
func (*Service) AgentWithdraw ¶ added in v0.5.0
func (s *Service) AgentWithdraw(ctx context.Context, c Caller, id draft.ID, rev int64, reason string) (draft.Draft, error)
AgentWithdraw drops held or failed draft id at rev for c, for reason, under AgentAmend's scope and rev checks; a held draft's gate is superseded by c's session.
func (*Service) Amend ¶ added in v0.4.0
Amend applies a, a person's at a.Rev, to held or failed draft id at once, all changes or none; its gate is handled as Edit's. A rev below 1 is ErrInvalid, a draft at another rev ErrRevConflict. An amendment by a session is refused (gates.ErrRefused): an agent revises through AgentAmend, stamped. A change the draft's kind does not let a person make is ErrInvalid (draft.ErrNotEditable).
func (*Service) ApplyPending ¶ added in v0.2.0
ApplyPending applies the effects of every sent draft not applied yet: a draft sent before a restart, or whose effects failed.
func (*Service) ApplySilently ¶ added in v0.6.0
ApplySilently applies effects on u with no draft and nothing posted, as a workflow step does; refused (ErrInvalid) unless SilentlyApplicable allows them.
func (*Service) BroadcastOf ¶ added in v0.4.0
BroadcastOf is the broadcast the draft p proposes would take: the one its publisher's Placer places, NoBroadcast when it replies in no thread or its publisher places nothing. It stores nothing and opens no gate.
func (*Service) CloseSilently ¶ added in v0.4.0
CloseSilently applies the effects of draft id, which a person discarded, without posting it: the draft keeps its state, its reason becomes draft.ReasonClosedSilently, then the Applier runs its effects. A failed effect is retried by ApplyPending. Refused (ErrInvalid) unless the draft was discarded by a person, declares effects and every one of them applies without a post.
func (*Service) DeliveryOf ¶ added in v0.3.0
DeliveryOf is where the delivery of draft gate g's draft stands; "" for a gate of another kind.
func (*Service) Discard ¶
Discard drops queued or failed draft id, whose gate a person approved: a held draft's discard is its gate's.
func (*Service) Edit ¶
func (s *Service) Edit(ctx context.Context, id draft.ID, text string, rev int64) (draft.Draft, error)
Edit sets the text of held or failed draft id, which the person read at rev. A held draft waits for a person again: its gate is superseded first, so no window and no approval given to the old text releases the new one, and a gate that waits opens.
func (*Service) Ended ¶ added in v0.4.0
Ended withdraws the held drafts of task id, a verb ended, as draft.WithdrawEnded, but those of a purpose keep names; it returns the drafts it withdrew.
func (*Service) GatesOf ¶ added in v0.7.0
GatesOf is the gate of each of ds that has one, read at once.
func (*Service) KindOf ¶ added in v0.5.0
KindOf is d's kind as the manifest of its publisher (PublisherOf), never of its unit, declares it now; false when that manifest declares none of that name.
func (*Service) List ¶
List is the drafts f selects, each with the delivery its kind posts as now (current).
func (*Service) Outbox ¶ added in v0.3.0
Outbox are the drafts waiting on the user, newest first: those whose gate is open, and those whose gate approved them and whose delivery failed or a restart has yet to settle.
func (*Service) PlaceBroadcasts ¶ added in v0.4.0
PlaceBroadcasts runs at daemon start: every held or failed draft but a reaction stored with no broadcast, as a version before broadcasts left it, takes the broadcast its publisher's Placer gives it now. A held draft is placed only while its gate is open, and then waits on a new gate at its new rev, so no approval of the unplaced draft posts the broadcast; a person retries a failed one. A draft placed in no thread, or whose publisher cannot place it now, keeps none and is asked again at the next start.
func (*Service) Prepare ¶ added in v0.3.0
Prepare readies held draft id for a person to approve its gate: the draft at rev, which its publisher must take, and not stale. It writes nothing. The caller reads the gate it resolves before it prepares: an edit after the person saw the draft supersedes that gate, and a person who changes the text approves through Edit's new gate.
func (*Service) Propose ¶
Propose stores the draft p proposes as held and opens its gate under p's approval: a policy that releases it queues it at once, a dry_run drops it, a delay gives the gate its window.
func (*Service) Publish ¶ added in v0.3.0
Publish is the consequence of draft gate g's resolution on its held draft: approved queues it for the sender, any other status drops it. A draft a rule or a window released fails instead, for a person to retry, when its publisher now posts it as another delivery than the one its approval decided, or when the workflow that proposed it no longer loads.
func (*Service) PublisherOf ¶ added in v0.3.0
func (s *Service) PublisherOf(d draft.Draft) unit.ProviderID
PublisherOf is the provider that posts d: its unit's when that one publishes, else the only provider of Targets whose publisher takes d's target, else its unit's.
func (*Service) Reask ¶ added in v0.5.0
Reask is Rehomed of every unit, run at start: a move made before the outbox loaded, or one a stop cut before Rehomed ran, leaves a draft's gate behind its rev.
func (*Service) Recover ¶
Recover runs once at daemon start: every sending draft -> Verify -> sent | failed, then the effects of every sent draft not applied yet; a draft whose provider answers ErrDisabled stays sending for the next Recover.
func (*Service) Rehomed ¶ added in v0.5.0
Rehomed asks a person again for each draft of units that a move to another unit took past the rev its gate approved or waits on: a held one waits on a new gate at its rev, and a queued one goes back to held under one, so its old approval neither posts it nor fails it.
func (*Service) Retry ¶
Retry: failed -> queued, only at the rev its gate approved, else ErrConflict, and only when no question decides it (QuestionPins). A draft that failed as "not confirmed after a restart" or with an Error starting "may have been posted" needs confirm true, else ErrNeedsConfirm.
func (*Service) RetryBy ¶ added in v0.5.0
func (s *Service) RetryBy(ctx context.Context, id draft.ID, confirm bool, by draft.Actor) (draft.Draft, error)
RetryBy is Retry by by: confirm, the word that the draft was not posted, is a person's alone, and an agent session's is refused (gates.ErrRefused), whether or not it proposed the draft.
func (*Service) Revisions ¶ added in v0.5.0
Revisions are draft id's content revisions, oldest first.
func (*Service) Send ¶
Send is the sender pass: the effects of the sent drafts not applied yet, then every approved draft -> sending -> sent | failed, one Publish each, no retry.
func (*Service) SetBroadcast ¶ added in v0.4.0
func (s *Service) SetBroadcast(ctx context.Context, id draft.ID, on bool, rev int64) (draft.Draft, error)
SetBroadcast turns on or off whether held or failed draft id, a thread reply the person read at rev, is also posted to its conversation; its gate is handled as Edit's.
func (*Service) SilentlyApplicable ¶ added in v0.6.0
func (s *Service) SilentlyApplicable(p unit.ProviderID, effects []string) error
SilentlyApplicable says why effects cannot apply on a unit of provider p with no draft, nil when they can: it names effects, every one of them applies without a post, and the Applier implements each for p.
func (*Service) Stale ¶ added in v0.5.0
Stale says whether the unit moved past the basis draft d was written against, read live now; false for a draft with no basis. A failed read, or no reader, is an error and says nothing of staleness.
func (*Service) Staleness ¶ added in v0.5.0
Staleness says whether draft d is stale, and known whether that can be told. A draft refused or failed as stale (draft.CauseStale) is, until its content is revised; one with no basis is not; any other compares its basis with the unit's, a recent read when Bases keep one (Recent), else a live one. A read that fails or does not answer before ctx ends leaves it unknown. It serves every reader but the checks that refuse a stale draft: a draft's card, its gate's options and a turn's instructions.
type SettledReader ¶ added in v0.4.0
type SettledReader interface {
SettledAt(ctx context.Context, workflow string) (map[unit.Unit]time.Time, error)
}
SettledReader is an optional capability of a Store: draft.SettledAt of every subject of a draft workflow proposed, read without the drafts' bodies; a subject with none is absent.
type Store ¶
type Store interface {
Insert(ctx context.Context, d draft.Draft) (draft.Draft, error) // assigns ID, at Rev 1 and Version 1
Get(ctx context.Context, id draft.ID) (draft.Draft, error) // ErrNotFound
List(ctx context.Context, f Filter) ([]draft.Draft, error) // newest first
// Update writes d only while the stored state is from and the stored Version is d.Version, and returns d
// with Version bumped, and Rev bumped when its Content changed; ErrConflict otherwise.
Update(ctx context.Context, d draft.Draft, from draft.State) (draft.Draft, error)
// Revisions are draft id's content revisions, oldest first; ErrNotFound when there is no such draft.
Revisions(ctx context.Context, id draft.ID) ([]draft.Revision, error)
}
Store keeps the drafts and their content revisions: Insert writes revision 1 by d.By, and Update writes a revision by d.By when d's Content (draft.SameContent) differs from the stored row's.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package outboxtest holds fakes of the Outbox's ports.
|
Package outboxtest holds fakes of the Outbox's ports. |