Documentation
¶
Overview ¶
Package data reads what the TUI shows: an immutable Snapshot taken in one read transaction, a Watcher that notices commits made by any other connection, and pane liveness. It never writes.
Index ¶
Constants ¶
const ClosedLimit = 200
ClosedLimit bounds the closed tasks a snapshot reads.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Request ¶
type Request struct {
ShowClosed bool // also the done, delivered and cancelled tasks
History []string // tasks whose every run is loaded (Snapshot.History)
}
Request says what a Load reads beyond the default set.
type Snapshot ¶
type Snapshot struct {
At time.Time
Projects []registry.ProjectRow
// Open are the tasks not done, delivered or cancelled; Deliverable the done tasks
// waiting for delivery (no review tasks); Closed, with Request.ShowClosed, the
// latest ClosedLimit done, delivered and cancelled tasks.
Open, Deliverable, Closed []task.Task
// ReviewOf maps a review task to the task it reviews (task_deps kind review_of).
ReviewOf map[string]string
// Runs are the active runs (coordinators included) and the newest run of every
// task in Open, Deliverable and Closed, newest first.
Runs []run.Run
// RunCount is the number of runs of each task that has any.
RunCount map[string]int
// History holds every run of the tasks in Request.History, newest first.
History map[string][]run.Run
Needs *msg.Needs
Asks []msg.OpenAsk
Inbox []msg.Item // unread messages to the human (peeked, not marked read)
Notes []notify.Notification // unread notifications, newest first
Unread int // unread notifications
Quota []quota.Row
Cooldown []quota.Cooldown
Profiles []registry.ProfileRow
// Unavailable maps the profiles new runs may not use now to why.
Daemon bool
// ReadOnly: the database schema is newer than this binary.
ReadOnly bool
}
Snapshot is what the database held at one moment. It is never changed once built.
func Load ¶
func Load(ctx context.Context, d *db.DB, dataDir string, req Request, now time.Time) (*Snapshot, error)
Load reads a Snapshot. Every query runs in one read-only transaction: a plain deferred BEGIN (modernc's _txlock=immediate applies only to write transactions), so the snapshot is consistent and never takes the write lock. It ends right after the queries; no read transaction is held between loads.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher notices commits to the database. It pins one connection and reads PRAGMA data_version on it, which changes whenever any other connection commits: the CLI, hooks, the daemon, and the TUI's own backend writes (other pool connections). One read costs microseconds and no IO beyond the shared-memory file.
func NewWatcher ¶
NewWatcher pins a connection of d for the watcher's lifetime.