Documentation
¶
Index ¶
- Constants
- func NewCountingPageStorage(next storage.PageStorage, metrics Metrics) storage.PageStorage
- func ResolveHead(vaultPath string) string
- type Config
- type GoalItem
- type Index
- func (i *Index) Build(ctx context.Context, store storage.PageStorage) error
- func (i *Index) GetGoal(id string) (GoalItem, bool, string)
- func (i *Index) GetTask(id string) (TaskItem, bool, string)
- func (i *Index) Head() string
- func (i *Index) QueryGoals() ([]GoalItem, int, int64)
- func (i *Index) QueryTasks(filter TaskFilter) ([]TaskItem, int, int64)
- func (i *Index) Readiness() Readiness
- type ListResponse
- type Metrics
- type Readiness
- type TaskFilter
- type TaskItem
Constants ¶
const ( // FileReadKindList counts files read while listing a directory. FileReadKindList = "page_list" // FileReadKindRead counts files read by a single-page lookup. FileReadKindRead = "page_read" )
File-read kinds. They are the label values of vault_api_file_reads_total and are bounded by construction, so the counter is pre-initialised for each.
const TaskTypeUnknown = "unknown"
TaskTypeUnknown is the label value used for a task whose frontmatter carries no task_type. It keeps the gauge's total equal to the real open-task count instead of silently dropping untyped pages.
Variables ¶
This section is empty.
Functions ¶
func NewCountingPageStorage ¶
func NewCountingPageStorage(next storage.PageStorage, metrics Metrics) storage.PageStorage
NewCountingPageStorage wraps a PageStorage so every file it reads increments vault_api_file_reads_total. The index build is the only caller that reads files; query handlers serve from the index and never reach this decorator, which is what makes a flat counter across a query window meaningful.
func ResolveHead ¶
ResolveHead reads the commit the vault working tree currently points at, shortened to 8 characters. It reads .git/HEAD and the ref file directly so the service needs no git binary in its image. An empty string means the directory is not a git working tree (or the ref could not be read).
Types ¶
type GoalItem ¶
type GoalItem struct {
ID string `json:"id"`
Title string `json:"title"`
Path string `json:"path"`
Status string `json:"status"`
Themes []string `json:"themes"`
Assignee string `json:"assignee,omitempty"`
Vault string `json:"vault"`
}
GoalItem is the typed projection of one goal page. It is served by GET /api/v1/goals and GET /api/v1/goals/{id}.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is the in-memory view of the vault. It is rebuilt at startup and again whenever the working tree's HEAD changes, so list queries are map lookups rather than per-file reads.
func NewIndex ¶
NewIndex creates an empty index. Build populates it and refreshes the open-task gauge.
func (*Index) Build ¶
Build reads every task and goal page and replaces the index atomically. A page whose frontmatter does not parse, or whose status/phase is present but not a known value, is excluded and counted in Warnings — never coerced.
func (*Index) GetTask ¶
GetTask resolves one task by identifier or filename slug. found is false when the id is absent; invalid carries the exclusion reason for a file that was refused rather than served.
func (*Index) QueryGoals ¶
QueryGoals returns every indexed goal, the warning count and the index age.
func (*Index) QueryTasks ¶
func (i *Index) QueryTasks(filter TaskFilter) ([]TaskItem, int, int64)
QueryTasks returns the tasks matching filter, the current warning count and the index age in seconds.
type ListResponse ¶
type ListResponse[T any] struct { Items []T `json:"items"` Total int `json:"total"` Warnings int `json:"warnings"` IndexAgeSeconds int64 `json:"index_age_seconds"` }
ListResponse is the envelope every list endpoint returns. Total is the number of items in the response; Warnings counts files excluded from the index because they could not be parsed or carry a value outside the enum.
type Metrics ¶
type Metrics interface {
AddFileReads(kind string, count int64)
SetOpenTasks(counts map[string]int)
}
Metrics is the instrumentation the storage decorator and the index write to.
func NewMetrics ¶
NewMetrics creates the service metrics and registers them. The file-read counter is pre-initialised with Add(0) so its series exists from boot — otherwise rate() is empty until the first read, and a counter diff taken across an index-served query window would be ambiguous.
stage and vault are constant labels: both are fixed for the lifetime of the process, and vault keeps two instances of the same stage from merging their per-type counts into one series at query time.
type Readiness ¶
type Readiness struct {
Ready bool `json:"ready"`
Vault string `json:"vault"`
IndexAgeSeconds int64 `json:"index_age_seconds"`
Head string `json:"head"`
Warnings int `json:"warnings"`
}
Readiness is the body of GET /readiness.
type TaskFilter ¶
TaskFilter narrows a task list. Empty fields are ignored; a query with no fields returns every indexed task.
type TaskItem ¶
type TaskItem struct {
ID string `json:"id"`
Title string `json:"title"`
Path string `json:"path"`
Status string `json:"status"`
Phase string `json:"phase"`
TaskType string `json:"task_type"`
Assignee string `json:"assignee"`
Goals []string `json:"goals"`
Cluster *string `json:"cluster"`
Flag bool `json:"flag"`
Vault string `json:"vault"`
}
TaskItem is the typed projection of one task page. It is served by GET /api/v1/tasks and GET /api/v1/tasks/{id}.