Documentation
¶
Overview ¶
Package links resolves linked items from events on the units they link to.
Index ¶
Constants ¶
const ( RetryAfter = time.Hour RetryNotFoundAfter = 24 * time.Hour ReadEndedEvery = 24 * time.Hour )
RetryAfter is how long a target whose read failed waits before the next, RetryNotFoundAfter when its source has no such unit or will not show it. ReadEndedEvery is how often a target that ended, and still settles nothing, is read: only a reopening would change it.
Variables ¶
var ErrNotReady = errors.New("the source cannot read yet")
ErrNotReady is a Refresher's answer while its source cannot read at all, such as a plugin still starting: Run fails with it, so its units run again soon, and the target waits for nothing.
Functions ¶
This section is empty.
Types ¶
type EventReader ¶
type Refresher ¶ added in v0.4.0
type Refresher interface {
// Refresh says whether it read u; a unit it holds fresh is not read.
Refresh(ctx context.Context, u unit.Unit) (read bool, err error)
}
Refresher reads a unit from its source again when what the host holds of it may be stale.
type Resolver ¶
type Resolver struct {
Links port.LinkStore
Events map[unit.ProviderID]EventReader // from source.Module.UnitEvents of enabled plugins
// Refresh reads a target an open item still waits on again, by provider; nil reads none.
Refresh map[unit.ProviderID]Refresher
Ledger items.Applier
Clock port.Clock
Log func(string, ...any)
// Codecs compare an actor's key with an assignee's; nil compares them byte for byte.
Codecs unit.KeyComparer
// contains filtered or unexported fields
}
func (*Resolver) Run ¶
Run resolves the open items linked to a unit of targets once every review and merge link of each settles, reading a target such an item still waits on again through Refresh.
func (*Resolver) Settles ¶ added in v0.4.0
func (r *Resolver) Settles(ctx context.Context, ls []link.Link, it ditems.Item) (ditems.Op, bool, error)
Settles is the op that settles it, open, through its review and merge links ls from the events their targets already have, as Run would apply it; ok is false while one of them does not settle. The items ledger calls it once a batch stored its links, so an item linked to pull requests that already ended resolves in the same batch, before any task holds it.