Documentation
¶
Overview ¶
Package readmodel keeps every unit's row derived, encoded and revised in memory, rebuilt from one store snapshot when a row input changes.
Index ¶
- Constants
- func BuildCatalog(providers ...Provider) api.CatalogResponse
- func CardSignal(s src.CardSignal) card.Signal
- func Login(p unit.ProviderID, id src.Identity) string
- func Unmuted(in any) any
- type Activities
- type Agents
- type AgentsFunc
- type Base
- type Booker
- type Books
- type Built
- type Entry
- type EventPresenter
- type Kept
- type LensPresenter
- type Model
- func (m *Model) Base(ctx context.Context) (Base, time.Time, error)
- func (m *Model) Catalog() api.CatalogResponse
- func (m *Model) Check(ctx context.Context) []string
- func (m *Model) Current(ctx context.Context) (Kept, error)
- func (m *Model) Labels(ctx context.Context) (map[unit.Unit]string, error)
- func (m *Model) Presentations(units []unit.Unit) map[unit.Unit]Presentation
- func (m *Model) Read(ctx context.Context, u unit.Unit) (Read, bool, error)
- func (m *Model) ReadMany(ctx context.Context, units []unit.Unit) (map[unit.Unit]Read, Base, time.Time, error)
- func (m *Model) Refresh(ctx context.Context) error
- func (m *Model) Row(ctx context.Context, u unit.Unit, asked catalog.Asked) (api.Row, bool, error)
- func (m *Model) Rows(ctx context.Context, since api.Since) (api.RowsPage, error)
- func (m *Model) Run(ctx context.Context, publish func(api.Change))
- func (m *Model) Served() bool
- func (m *Model) Since(ctx context.Context, since api.Since) (api.Change, error)
- func (m *Model) UseClock(now func() time.Time)
- func (m *Model) UseKeeper(keep func(ctx context.Context, k Kept))
- func (m *Model) UseLog(logf func(format string, args ...any))
- type Mutes
- type Notice
- type Noticer
- type Plans
- type Presentation
- type Presenter
- type Provider
- type Read
- type ReasonPresenter
- type Reported
- func (p *Reported) Card(ctx context.Context, row api.Row) (card.Card, error)
- func (p *Reported) CardSignals() []api.SignalSpec
- func (p *Reported) Derive(base Base, in any, at time.Time) (api.Row, error)
- func (p *Reported) Details() []api.DetailSpec
- func (p *Reported) Events() []api.EventSpec
- func (p *Reported) Facets() []api.FacetSpec
- func (p *Reported) Lens() api.ProviderWords
- func (p *Reported) Listed(ctx context.Context) ([]unit.Unit, error)
- func (p *Reported) Load(ctx context.Context, units []unit.Unit) (map[unit.Unit]any, error)
- func (p *Reported) Provider() unit.ProviderID
- func (p *Reported) Reasons() api.ProviderWords
- func (p *Reported) Signals(_ Base, _ api.Row, in any, _ time.Time) map[string]bool
- func (p *Reported) Situations() []api.SituationSpec
- func (p *Reported) Unmuted(in any) any
- func (p *Reported) Views() []api.ViewSpec
- type ReportedSource
- type Reports
- type RowDeps
- type RowSettings
- type Sessions
- type Settings
- type SignalPresenter
- type Signaler
- type Snapshotter
- type Summary
- type Unmuter
- type WakeMutes
Constants ¶
const FacetWaitsOn = "waits-on"
FacetWaitsOn is the facet of whom a row waits on, by login or team.
const PokeQuiet = 250 * time.Millisecond
PokeQuiet is how long the model waits after a row note before it refreshes, so a burst of notes costs one refresh.
Variables ¶
This section is empty.
Functions ¶
func BuildCatalog ¶
func BuildCatalog(providers ...Provider) api.CatalogResponse
BuildCatalog is the served presentation of the providers that are Presenters, in their order; a view id another provider took first is left out, and a provider's view orders follow the previous providers'.
func CardSignal ¶ added in v0.4.0
func CardSignal(s src.CardSignal) card.Signal
CardSignal is a plugin's card signal as a card holds it.
Types ¶
type Activities ¶ added in v0.2.0
type Activities interface {
Activities(ctx context.Context, provider unit.ProviderID) (map[unit.Unit]turn.Activity, error)
}
Activities reads what the loop spent on a provider's units, those with any.
type Agents ¶
type Agents interface {
Agents() (agents []turns.AgentObservation, ok bool)
}
Agents is the agents' last known states; ok is false when they are unknown.
type AgentsFunc ¶
type AgentsFunc func() ([]turns.AgentObservation, bool)
AgentsFunc adapts a function to Agents.
func (AgentsFunc) Agents ¶
func (f AgentsFunc) Agents() ([]turns.AgentObservation, bool)
type Base ¶
type Base struct {
// Viewers and Teams are the viewer's login and teams in each source, as
// its plugin's Identity says.
Viewers map[unit.ProviderID]string
Teams map[unit.ProviderID][]string
Specs []api.ActionSpec
// SpecsVersion is the version of GET /api/actions the rows' actions follow.
SpecsVersion string
// Intents are the loaded intents whose actions a row of a provider other than GitHub offers; nil offers
// none.
Intents *intentload.Loaded
// Plans are the automatic rounds the open plan gates hold, by unit.
Plans map[unit.Unit]overlay.Pending
Agents []turns.AgentObservation
// AgentsOK is false when the agents are unknown, so no session can be
// told waiting.
AgentsOK bool
// Asked is the action a request asks for; zero for a served row.
Asked catalog.Asked
}
Base is what every row of a rebuild shares, built once per rebuild.
type Booker ¶ added in v0.3.0
Booker is optional on a Provider: the turn book in, a row input of the provider, holds; has is false for a unit with none.
type Books ¶
type Books interface {
Books(ctx context.Context, units ...unit.Unit) (map[unit.Unit]turn.Book, error)
}
Books reads turn books.
type Entry ¶
Entry is one unit's row as served: JSON is Row encoded, Rev the revision at which JSON last changed.
type EventPresenter ¶ added in v0.3.0
type EventPresenter interface {
Events() []api.EventSpec
Details() []api.DetailSpec
}
EventPresenter is optional on a Presenter: the words of its event kinds.
type Kept ¶
Kept is a snapshot as its keeper sees it: the base, the minute and every row, shared with the snapshot and read-only.
type LensPresenter ¶ added in v0.4.0
type LensPresenter interface {
Lens() api.ProviderWords
}
LensPresenter is optional on a Presenter: its own row words.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model serves every provider's rows from one immutable snapshot, rebuilt whole when a row input changed or the minute moved.
func New ¶
func New(changes port.Changes, snap Snapshotter, plans Plans, agents Agents, settings Settings, providers ...Provider) *Model
New builds a model over the providers. A nil changes rebuilds on every read; nil plans, agents or settings leave their Base fields zero.
func (*Model) Base ¶
Base is what the current snapshot's rows share, and the minute they were derived at.
func (*Model) Catalog ¶
func (m *Model) Catalog() api.CatalogResponse
Catalog is the served presentation of the model's providers.
func (*Model) Check ¶
Check derives every row from scratch at the snapshot's minute and lists each unit whose served row differs, with the fields that differ; none when the snapshot matches or none was served yet.
func (*Model) Current ¶
Current is the snapshot that holds every write noted before the call, as its keeper sees it. Its rows are shared: read them, never change them.
func (*Model) Labels ¶
Labels are the labels of every unit a provider lists, as their rows show them.
func (*Model) Presentations ¶
Presentations are the presentations of the units the snapshot lists, without a sync.
func (*Model) Read ¶
Read is u's entry; ok is false for a unit no provider lists. The row is a copy the caller may change; In is shared and must not be.
func (*Model) ReadMany ¶
func (m *Model) ReadMany(ctx context.Context, units []unit.Unit) (map[unit.Unit]Read, Base, time.Time, error)
ReadMany is the entries of the units any provider lists, from one snapshot, with the base and the minute it holds.
func (*Model) Refresh ¶
Refresh brings the snapshot up to date and runs the keeper on it if it is new, as Run does on each note and minute.
func (*Model) Row ¶
Row is a copy of u's row, derived for a request that asks for an action; ok is false for a unit no provider lists.
func (*Model) Rows ¶
Rows are the rows: all of them when since is zero, of another epoch, ahead of Rev or behind the tombstones, else those that changed after since and the units that left. The rows are copies the caller may change.
func (*Model) Run ¶
Run keeps the snapshot current until ctx ends: it rebuilds on a row input's note, debounced, and on the minute, and publishes a Change each time the revision moved, starting from the model's first snapshot, since a client may have read it before Run started.
func (*Model) Since ¶
Since is what a client at since missed: the units whose row changed or left after it, or All when since is of another epoch, ahead of Rev or behind the tombstones. A zero since missed nothing, so its Change only says where the rows are.
type Mutes ¶ added in v0.3.0
type Mutes interface {
Mutes(ctx context.Context, units []unit.Unit) (map[unit.Unit]overlay.Mute, error)
}
Mutes reads the user's mutes of units; a unit with none is absent.
type Notice ¶ added in v0.3.0
type Notice struct {
// Gate is the kind of the gate the notice stands for, which keys it on
// the unit's task; "" for one no gate stands for.
Gate gate.Kind
// Held says the notice is of a held round; Question of the open
// question of the turn record Record.
Held, Question bool
Record int64
// Token lasts as long as what is notified.
Token string
// Attention carries no ID and no Category, which the caller keys.
Attention api.Attention
}
Notice is what a row notifies, as its provider derives it.
type Noticer ¶ added in v0.3.0
Noticer is optional on a Provider: what row, derived from in at at, notifies; ok is false when it notifies nothing.
type Presentation ¶
type Presentation struct{ Label, Title, Link string }
Presentation is a unit's label, title and link as its row shows them.
type Presenter ¶
type Presenter interface {
Views() []api.ViewSpec
Facets() []api.FacetSpec
Situations() []api.SituationSpec
}
Presenter is optional on a Provider: its served views, facets and situations, read once per catalog build.
type Provider ¶
type Provider interface {
Provider() unit.ProviderID
// Listed are the units the provider serves a row for.
Listed(ctx context.Context) ([]unit.Unit, error)
// Load reads what the rows of units derive from; a unit missing from
// the result has no row.
Load(ctx context.Context, units []unit.Unit) (map[unit.Unit]any, error)
// Derive is pure: the row of one unit from base and what Load read,
// with the Link and Label Load read; the model sets the row's Unit.
Derive(base Base, in any, at time.Time) (api.Row, error)
}
Provider is one provider's rows.
type Read ¶
type Read struct {
Row api.Row
In any
Base Base
At time.Time
// contains filtered or unexported fields
}
Read is one unit's entry of a snapshot: the served row, what it derives from and the base it was derived with.
func (Read) Book ¶ added in v0.3.0
Book is the turn book the read's input holds; kept is false when its provider keeps no book, so the caller reads it.
func (Read) Derive ¶
Derive is the unit's row from base and in, at the minute of the snapshot, on the read's unit.
func (Read) Notice ¶ added in v0.3.0
Notice is what the read's row notifies; ok is false when it notifies nothing or its provider notifies no row.
type ReasonPresenter ¶ added in v0.4.0
type ReasonPresenter interface {
Reasons() api.ProviderWords
}
ReasonPresenter is optional on a Presenter: its words of the reasons its rows name.
type Reported ¶ added in v0.3.0
type Reported struct {
// contains filtered or unexported fields
}
Reported serves a source plugin's units as rows: each unit's last snapshot under the host's overlays, with no call to the plugin. The overlays are the run that drives the row, the mute and the pending round; an open intake shows in the row's line.
func NewReported ¶ added in v0.3.0
func NewReported(src ReportedSource) *Reported
NewReported is the provider of src's units.
func (*Reported) Card ¶ added in v0.3.0
Card is a reported unit's card: its plugin's, under the overlays its row shows. A row whose situation an overlay set says why and on whom in the card too.
func (*Reported) CardSignals ¶ added in v0.4.0
func (p *Reported) CardSignals() []api.SignalSpec
func (*Reported) Details ¶ added in v0.3.0
func (p *Reported) Details() []api.DetailSpec
func (*Reported) Lens ¶ added in v0.4.0
func (p *Reported) Lens() api.ProviderWords
func (*Reported) Load ¶ added in v0.3.0
Load reads each unit's last snapshot, its turn book and session, its mute and its open intake. A unit with no snapshot has no row.
func (*Reported) Provider ¶ added in v0.3.0
func (p *Reported) Provider() unit.ProviderID
func (*Reported) Reasons ¶ added in v0.4.0
func (p *Reported) Reasons() api.ProviderWords
func (*Reported) Signals ¶ added in v0.3.0
Signals are the link signals the plugin reported of the unit.
func (*Reported) Situations ¶ added in v0.3.0
func (p *Reported) Situations() []api.SituationSpec
type ReportedSource ¶ added in v0.3.0
type ReportedSource struct {
RowDeps
ID unit.ProviderID
Reports Reports
Mutes Mutes
// Viewer is the user as the plugin's people are keyed, whom a card
// waiting on the user names; nil names nobody.
Viewer func(ctx context.Context) items.Person
// Stale says u's plugin no longer stands behind its last report; nil
// says none is.
Stale func(u unit.Unit) bool
// Catalog is the plugin's views, facets and situations; nil serves none.
Catalog Presenter
}
ReportedSource is what a source plugin's rows read: its reports and the host's own state. Mutes may be nil: no unit is muted.
type Reports ¶ added in v0.3.0
type Reports interface {
// Units are p's units with a snapshot.
Units(ctx context.Context, p unit.ProviderID) ([]unit.Unit, error)
// Reported are units' last snapshots; a unit with none is absent.
Reported(ctx context.Context, units []unit.Unit) (map[unit.Unit]src.Snapshot, error)
}
Reports reads what source plugins last reported of their units.
type RowDeps ¶
type RowDeps struct {
Books Books
Sessions Sessions
Activity Activities
// Intakes are the open intakes, the oldest first.
Intakes func(ctx context.Context) ([]intake.Intake, error)
// Intake is a row's view of an open intake, from its unit's brief;
// attempt is the brief attempt the intake waits on.
Intake func(i intake.Intake, b intake.BriefState, attempt func() (int, error)) api.Intake
Settings func() RowSettings
Logf func(format string, args ...any)
}
RowDeps are what the daemon supplies to any provider's rows. Books, Sessions, Activity, Intakes and Intake may be nil: no turns, no sessions, no activity, no intakes.
type RowSettings ¶
type RowSettings struct {
Cfg config.Config
Loaded *intentload.Loaded
GateOn bool
// Forceable is the last remove refusal of a unit that force gets past,
// "" for none.
Forceable func(unit.Unit) string
}
RowSettings is what every row reads of the configuration, the profile and the daemon, read once per load.
type Sessions ¶
type Sessions interface {
// Sessions lists the sessions not closed.
Sessions(ctx context.Context) ([]turn.Session, error)
Session(ctx context.Context, handle string) (turn.Session, bool, error)
}
Sessions reads the managed sessions.
type Settings ¶
Settings supplies the Base fields no other port does: viewers, teams and action specs.
type SignalPresenter ¶ added in v0.4.0
type SignalPresenter interface {
CardSignals() []api.SignalSpec
}
SignalPresenter is optional on a Presenter: its words of its cards' signals.
type Signaler ¶ added in v0.3.0
Signaler is optional on a Provider: the link signals of row, derived from in at at, under the host's overlays, by name.
type Snapshotter ¶
type Snapshotter interface {
Snapshot(ctx context.Context, fn func(ctx context.Context) error) error
}
Snapshotter runs fn with every store read made with its ctx inside one read transaction.
type Unmuter ¶ added in v0.3.0
Unmuter is optional on a Provider: in, a row input of the provider, derived as if the user had not muted its unit.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cards keeps the units' card snapshots and derived items current with the rows the read model publishes.
|
Package cards keeps the units' card snapshots and derived items current with the rows the read model publishes. |
|
Package overlay lays the host's own state over a unit's situation as its source derives it: the loop's run on the unit, the user's mute and a pending round.
|
Package overlay lays the host's own state over a unit's situation as its source derives it: the loop's run on the unit, the user's mute and a pending round. |
|
Package prrow derives the row of a pull request from what the store, the gate and the turns say of it: the github provider of the read model.
|
Package prrow derives the row of a pull request from what the store, the gate and the turns say of it: the github provider of the read model. |
|
ghreporttest
Package ghreporttest derives the GitHub plugin's snapshot of a pull request the host's tests hold as inventory rows, with the plugin's own code, so a host test renders the rows the running plugin's reports render.
|
Package ghreporttest derives the GitHub plugin's snapshot of a pull request the host's tests hold as inventory rows, with the plugin's own code, so a host test renders the rows the running plugin's reports render. |