state

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package state owns bitc's on-disk layout (spec 9).

Index

Constants

View Source
const SchemaVersion = 1

SchemaVersion is the state-dir schema this binary writes and understands.

Variables

This section is empty.

Functions

func AccountDir

func AccountDir(e *config.Effective) (string, error)

AccountDir is <passwd home>/.local/state/bitc/account (spec 2, 9). No env, flag or key moves it, so a private BITC_DIR or BITC_CONFIG cannot multiply the cap; only [test] accounting_dir.

func AppendHistory

func AppendHistory(path string, e Event, red *redact.Set) error

AppendHistory appends one redacted JSON line with a single O_APPEND write.

func Check added in v0.1.2

func Check(root string) error

Check runs Open's refusals on an existing state dir without creating or writing anything; a missing dir passes, since the first command creates it 0700.

func Install16

func Install16(secret []byte) string

Install16 is 16 hex of sha256(secret).

func InstallSecret

func InstallSecret(dir string) ([]byte, error)

InstallSecret returns the 32-byte install secret, creating it once. The file appears atomically (a full temp file linked into place), so no reader sees a partial secret; a file of any other length is an error rather than a key.

func MkdirPrivate

func MkdirPrivate(path string) error

MkdirPrivate creates path and missing parents with 0700 and checks path itself: owned by the user, not group- or world-accessible.

func WriteFileAtomic

func WriteFileAtomic(path string, b []byte) error

WriteFileAtomic writes b to path (0600) through a temp file and rename.

Types

type Event

type Event struct {
	TS            string   `json:"ts"`
	Event         string   `json:"event"` // start | end | starved | fallback | reaped
	Pool          string   `json:"pool"`
	Slot          int      `json:"slot,omitempty"`
	Job           string   `json:"job"`
	Pid           int      `json:"pid"`
	Nested        bool     `json:"nested,omitempty"`
	Argv          []string `json:"argv"`
	ArgvTruncated bool     `json:"argv_truncated,omitempty"`
	Cwd           string   `json:"cwd"`
	Provider      string   `json:"provider"`
	Resource      string   `json:"resource,omitempty"`
	Sha           string   `json:"sha,omitempty"`
	WaitMS        *int64   `json:"wait_ms,omitempty"`
	RunMS         *int64   `json:"run_ms,omitempty"`
	Exit          *int     `json:"exit,omitempty"`
	Outcome       string   `json:"outcome,omitempty"`
	Reason        string   `json:"reason,omitempty"`
}

Event is one history.jsonl line (spec 9). Refusals write nothing.

type Layout

type Layout struct{ Root string }

Layout names every path in a state dir. Root is absolute.

func Open

func Open(root string) (Layout, error)

Open creates the state dir (0700) or checks an existing one, then checks SCHEMA. Every refusal is 78 (spec 9).

func (Layout) AdmitLock

func (l Layout) AdmitLock() string

func (Layout) GroupUnitLock

func (l Layout) GroupUnitLock(g string, j int) string

func (Layout) History

func (l Layout) History() string

func (Layout) JobDir

func (l Layout) JobDir(wt8, name string) string

func (Layout) JobsDir

func (l Layout) JobsDir() string

func (Layout) NestLock

func (l Layout) NestLock(p string, i, depth int) string

func (Layout) PoolDir

func (l Layout) PoolDir(p string) string

func (Layout) Reservations

func (l Layout) Reservations() string

func (Layout) Schema

func (l Layout) Schema() string

func (Layout) SlotLock

func (l Layout) SlotLock(p string, i int) string

func (Layout) Tickets

func (l Layout) Tickets(p string) string

Jump to

Keyboard shortcuts

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