Documentation
¶
Overview ¶
Package cli holds the daemon's command implementations.
Index ¶
- Constants
- Variables
- func AcquireLock(dataDir string) (release func(), err error)
- func Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) int
- func RunWithHooks(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer, ...) int
- type Hooks
- type Runner
- type StatsLimit
- type StatsOut
- type StatsSession
- type StatsSync
- type StatsToday
Constants ¶
const ( StateOK = "ok" StateBacklog = "backlog" StateBlocked = "blocked" StateOffline = "offline" StateLoggedOut = "logged_out" )
Sync states of StatsSync.State.
const StatsTTL = 30 * time.Second
StatsTTL is how long a fetched answer is reused.
const StatsVersion = 1
StatsVersion is the version of the `braid stats --json` contract (band/stats.schema.json).
Variables ¶
var ErrLocked = errors.New("another braid process is syncing")
ErrLocked is returned by AcquireLock when another process holds the lock.
Functions ¶
func AcquireLock ¶
AcquireLock takes <data>/braid.lock non-blocking; returns ErrLocked if held.
Types ¶
type Hooks ¶
type Hooks struct {
NoKeychain bool // keychain Set fails with auth.ErrNoKeychain
FakeToken string // skip the device flow and use this token
ConfigDir string // overrides the config dir
DataDir string // overrides the data dir
Now func() time.Time // nil means time.Now
}
Hooks override environment lookups. Only meant for tests; Run uses the zero value.
type Runner ¶
type Runner struct {
Engine *syncer.Engine
Trigger <-chan struct{}
Backoff client.Backoff
Log *slog.Logger
Sleep func(ctx context.Context, d time.Duration) error // default: timer with ctx
// contains filtered or unexported fields
}
Runner drives sync passes from triggers.
type StatsLimit ¶
type StatsLimit struct {
Type string `json:"type"`
ResetsAt string `json:"resets_at"` // RFC 3339 UTC
}
StatsLimit is the active usage limit.
type StatsOut ¶
type StatsOut struct {
Version int `json:"version"`
Sync StatsSync `json:"sync"`
Today StatsToday `json:"today"`
Session *StatsSession `json:"session,omitempty"`
Limit *StatsLimit `json:"limit,omitempty"`
}
StatsOut is the output of `braid stats --json`.
type StatsSession ¶
type StatsSession struct {
CostUSD float64 `json:"cost_usd"`
Tokens int64 `json:"tokens"`
Failures int64 `json:"failures"`
}
StatsSession is the figures of the requested session.