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
- type Agents
- type AgentsFunc
- type Base
- type Books
- type Built
- type Entry
- type Kept
- 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(units []unit.Unit) map[unit.Unit]string
- 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, view string, 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 Pending
- type Presentation
- type Presenter
- type Provider
- type Read
- type RowDeps
- type RowSettings
- type Sessions
- type Settings
- type Snapshotter
- type Summary
Constants ¶
const FacetWaitsOn = "waits-on"
FacetWaitsOn is the facet of whom a row waits on, by login or team.
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'.
Types ¶
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 map[unit.ProviderID]string
Teams []string // the github viewer's teams
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
Pending map[unit.Unit]round.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 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 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 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, pending Pending, agents Agents, settings Settings, providers ...Provider) *Model
New builds a model over the providers. A nil changes rebuilds on every read; nil pending, 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 units in the latest snapshot, such as "owner/repo#12" or "#channel"; a unit it does not list has none. It never rebuilds the rows.
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 is the view's 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.
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 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.
type RowDeps ¶
type RowDeps struct {
Books Books
Sessions Sessions
// 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 record
// (found false: none); attempt is the brief attempt the intake waits on.
Intake func(i intake.Intake, rec dinv.BriefRecord, found bool, 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, Intakes and Intake may be nil: no turns, no sessions, 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.
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 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. |