Documentation
¶
Overview ¶
Package views projects every pull request's item view to the sinks that show it.
Index ¶
Constants ¶
const ( KindViewApplied = "view_applied" KindViewOverride = "view_override" KindViewSinkFailed = "view_sink_failed" )
The kinds of the events the views write; none is keyed.
const FlushDebounce = time.Second
FlushDebounce is how long a sink's worker waits after a wake before it flushes, so the wakes of one round share a flush.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Books ¶
type Books interface {
// Books returns the book of each ref, or of every pull request with a
// turn when none is named.
Books(ctx context.Context, refs ...unit.Unit) (map[unit.Unit]turn.Book, error)
}
Books is what the views read of the turns.
type Facts ¶
type Facts interface {
// Author returns the facts of u's pull request, with the checkout's when
// needLocal; nil when u has none.
Author(ctx context.Context, u unit.Unit, needLocal bool) (*view.AuthorFacts, error)
}
Facts is what the views read of a pull request to project its author card.
type ItemError ¶
ItemError is a sink's failure to write one item. A sink joins one per failed item into Apply's error, so only those items are retried; an error that names no item fails every item the sink did not apply.
type PlacementReader ¶
type Service ¶
type Service struct {
Books Books
Intents Intents
State State
Sinks []Sink
Pub port.Publisher
Clock port.Clock
Log func(format string, args ...any)
Backoff func(failures int) time.Duration // nil: 1 s doubling to 5 minutes
Paused func(ctx context.Context, ref unit.Unit) bool // true keeps ref's items queued, unapplied
Facts Facts // nil projects the turns alone
Changes port.Changes // nil, like a set Facts, reconciles every pull request every time
Debounce time.Duration // 0 flushes at once on a wake; production sets FlushDebounce
// contains filtered or unexported fields
}
Service projects every pull request's book to each sink through the sink's own queue, so a failing sink never delays another or the caller.
func (*Service) Changed ¶
Changed recomputes the items of refs and queues those that differ from what each sink last received.
func (*Service) Reconcile ¶
Reconcile queues, for the pull requests that may differ, each item that differs from what the sink last received or from where the user placed its card, and returns how many it queued. With a change log, the pull requests are those noted since the last reconcile and those whose card sits where the sink did not put it; every pull request with a turn on the first run, after a config or all note, with Facts, and without a log. Sinks are read concurrently, so a slow one does not hold back another's queue.
func (*Service) RoundStarted ¶
RoundStarted queues ref's items for every sink with force, so the column is written whatever the card shows and the override is cleared.
type Sink ¶
type Sink struct {
ViewSink
Placements PlacementReader // nil for a push-only sink
}
type State ¶
type State interface {
Applied(ctx context.Context, sink string) (map[view.Key]view.Applied, error)
// SaveApplied replaces the sink's row of a.Key().
SaveApplied(ctx context.Context, sink string, a view.Applied, evs ...port.Event) error
// SaveFailure stores the events of a write a sink refused.
SaveFailure(ctx context.Context, evs ...port.Event) error
}
State is what every sink last received.
type StatusReader ¶
StatusReader is a sink that can say which status a column of its board is, None when the column is not one it writes for role.
type ViewSink ¶
type ViewSink interface {
Name() string
// Manages reports whether column is in the vocabulary the sink manages
// for cards of role; outside it the user's placement wins.
Manages(role view.Role, column string) bool
// Apply writes each item's column when force holds its unit, its
// card is in a managed column or in none; otherwise only the summary and
// unread, with Applied.Override set to the user's column. An item with no
// status is not written.
Apply(ctx context.Context, items []view.Item, force map[unit.Unit]bool) ([]view.Applied, error)
}