views

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package views projects every pull request's item view to the sinks that show it.

Index

Constants

View Source
const (
	KindViewApplied    = "view_applied"
	KindViewOverride   = "view_override"
	KindViewSinkFailed = "view_sink_failed"
)

The kinds of the events the views write; none is keyed.

View Source
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

func NewestOwnsTheCard

func NewestOwnsTheCard(items []view.Item, cardOf func(unit.Unit) (string, bool)) []view.Item

NewestOwnsTheCard keeps, of the units that share a card, only the newest unit's items; ties go to the greater unit. Items whose unit has no card stay.

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 Gates added in v0.3.0

type Gates interface {
	Where(ctx context.Context, q gates.Query) ([]gate.Gate, error)
}

Gates are the decisions waiting on the user; a unit's cards wait on them while one of its gates is open.

type Intents

type Intents interface {
	All() []dintent.Def
}

Intents is the registry the views read the intents of each board from.

type ItemError

type ItemError struct {
	Key view.Key
	Err error
}

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.

func (*ItemError) Error

func (e *ItemError) Error() string

func (*ItemError) Unwrap

func (e *ItemError) Unwrap() error

type PlacementReader

type PlacementReader interface {
	// Placements is the column the user sees for each unit's card.
	Placements(ctx context.Context) (map[unit.Unit]string, error)
}

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
	Gates    Gates                                         // nil reads no gate open
	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

func (s *Service) Changed(ctx context.Context, refs ...unit.Unit)

Changed recomputes the items of refs and queues those that differ from what each sink last received.

func (*Service) Reconcile

func (s *Service) Reconcile(ctx context.Context) (rewritten int, err error)

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

func (s *Service) RoundStarted(ctx context.Context, ref unit.Unit)

RoundStarted queues ref's items for every sink with force, so the column is written whatever the card shows and the override is cleared.

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run runs one worker per sink until ctx ends.

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

type StatusReader interface {
	Status(role view.Role, column string) view.Status
}

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)
}

Directories

Path Synopsis
Package viewstest holds the contracts every views port implementation passes, and the fakes the core's tests use.
Package viewstest holds the contracts every views port implementation passes, and the fakes the core's tests use.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL