Documentation
¶
Overview ¶
Package view keeps live, ordered message lists for clients (the view domain in docs/specs/rpc-api.md).
Index ¶
- Constants
- Variables
- func Diff(old, new []int64) []api.ViewOp
- type Manager
- func (m *Manager) Close(conn api.Conn, id int64) error
- func (m *Manager) Filter(conn api.Conn, id int64) (store.ViewFilter, error)
- func (m *Manager) OnCommit(evs []api.EventEnvelope)
- func (m *Manager) Open(ctx context.Context, conn api.Conn, f store.ViewFilter) (int64, int, error)
- func (m *Manager) Range(conn api.Conn, id int64, start, end int) ([]int64, error)
- func (m *Manager) Run(ctx context.Context)
Constants ¶
const Debounce = 50 * time.Millisecond
Debounce is how long the manager waits after a change before recomputing views, so a burst of commits (an initial sync) costs one recompute.
Variables ¶
var ErrNotFound = errors.New("view: not found")
ErrNotFound means the view does not exist or belongs to another connection.
Functions ¶
func Diff ¶
Diff turns an old view into the ops that produce new. IDs are unique within each list. The rows that stay put are a longest strictly increasing subsequence of the new indexes of the shared IDs, so a small edit stays a small delta. Removes come first, from the end of old toward the start, so earlier indexes stay valid; then inserts, from the start of new toward the end, where each run lands exactly at its new index. Diff returns nil when nothing changed.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager keeps the open views. Each is an ordered ID snapshot owned by one connection; after relevant commits the manager recomputes it and sends the owner a view.delta.
func NewManager ¶
NewManager returns a Manager; Run must be running for views to update.
func (*Manager) OnCommit ¶
func (m *Manager) OnCommit(evs []api.EventEnvelope)
OnCommit marks views affected by committed events dirty; it is chained into the store's OnCommit hook and never blocks.