Documentation
¶
Overview ¶
Package wakes matches the wakes on tasks against time, events and their conditions, and emits task.woke for the profile's workflows.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Store Store
Tasks Tasks
// Holds says whether a wake's When holds; nil: no condition holds.
Holds Holds
Clock port.Clock
}
Deps are what the wakes run on.
type Holds ¶
Holds says whether wake w's When holds over task t's facts; injected, so the core matches a condition without importing the package that evaluates the profile's predicates.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service matches the wakes: a wake whose Until passed, whose When holds or one of whose On an event matches wakes its task; one whose Expires passed first is dropped unmatched. Waking records task.woke on the task, with the wake's Return as its data, and spends the wake: it keeps only its Return, which matches nothing, for the profile's wake workflow to read.
func (*Service) Event ¶
Event matches the wake of task id against an event of kind by actor on the task or a unit it holds.
type Store ¶
type Store interface {
// Put sets the task's wake, replacing the one it had.
Put(ctx context.Context, w wake.Wake) error
// Drop removes the task's wake; dropping none is no error.
Drop(ctx context.Context, id task.ID) error
// Of is task id's wake, false when it has none.
Of(ctx context.Context, id task.ID) (wake.Wake, bool, error)
// Due are the wakes whose Until or Expires is set and not after now,
// ordered by task id.
Due(ctx context.Context, now time.Time) ([]wake.Wake, error)
// Watching are the wakes with On or When set, which events and fact
// changes match, ordered by task id.
Watching(ctx context.Context) ([]wake.Wake, error)
}
Store keeps one wake per task.
type Tasks ¶
type Tasks interface {
Task(ctx context.Context, id task.ID) (task.Task, error)
Apply(ctx context.Context, cs []task.Change, evs ...port.Event) error
}
Tasks are the tasks the wakes are on, and where a matched wake's task.woke event is recorded. Task fails with tasks.ErrNoTask for a task it does not hold.