ledger

package
v0.2.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package ledger is an append-only store of completed ushr jobs. The controller appends a record per workflow_job webhook; `ushr cost` reads them to total runner-minutes without re-scanning GitHub.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath is where the ledger lives when config doesn't set webhook.ledger_path.

func PathOrDefault

func PathOrDefault(configured string) string

PathOrDefault resolves a configured ledger path, falling back to DefaultPath.

Types

type Ledger

type Ledger struct {
	// contains filtered or unexported fields
}

Ledger appends records as JSON lines to a file. Append is safe for concurrent use; the file is the single source of truth, opened per write.

func Open

func Open(path string) (*Ledger, error)

Open returns a Ledger writing to path, creating the parent directory.

func (*Ledger) Append

func (l *Ledger) Append(r Record) error

Append writes one record as a JSON line.

type Record

type Record struct {
	JobID       int64     `json:"job_id"`
	Org         string    `json:"org"`
	Repo        string    `json:"repo"`
	Workflow    string    `json:"workflow,omitempty"`
	RunID       int64     `json:"run_id,omitempty"`
	Conclusion  string    `json:"conclusion,omitempty"`
	Labels      []string  `json:"labels"`
	RunnerName  string    `json:"runner_name"`
	CreatedAt   time.Time `json:"created_at,omitzero"`
	StartedAt   time.Time `json:"started_at"`
	CompletedAt time.Time `json:"completed_at"`
}

Record is one completed job served by an ushr runner.

func Read

func Read(path string) ([]Record, error)

Read returns every record. A missing file is an empty ledger, not an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL