rails

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 19 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 rails is the shared remote safety rails (spec 8.3).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapNote

func CapNote(daily, spent, committed, job config.Micros) string

CapNote is the fallback text (spec 8.3), two decimals.

func Check

func Check(ctx context.Context, j *remote.Job) (func(), error)

Check runs breaker, launch lock, cap and max_live (spec 8.3) and records a reservation; the release func drops the reservation (at the job's ledger end) and is idempotent.

func DropOrphan

func DropOrphan(dir, name string)

DropOrphan removes the orphan reservation for name (its resource was confirmed gone).

func LedgerToday

func LedgerToday(dir string, now time.Time) config.Micros

LedgerToday is today's (UTC) spend this host saw: the cost of every ended job that created a resource. Open launches are left out (their resource is in L, or their reservation counts), so a running job is counted once; a job that created nothing (a capacity fallback) costs nothing (spec 8.3, spec 14 "a running job is counted once").

func LiveReservations

func LiveReservations(dir string) map[string]bool

LiveReservations lists the names with a non-orphan reservation in dir/reservations.json.

func OrphanNames

func OrphanNames(dir string) map[string]bool

OrphanNames lists the names whose only reservation in dir/reservations.json is an orphan.

func Pause

func Pause(dir, why string, window time.Duration) error

Pause: one record per ErrUnavailable; launches are refused until now + window.

func Paused

func Paused(dir string, b config.Breaker, now time.Time) (string, bool)

Paused reports whether launches are refused now, and why.

func PruneReservationsIn

func PruneReservationsIn(dir string, dry bool) []string

PruneReservationsIn drops expired reservations and those whose process is gone from dir/reservations.json under the launch lock (bounded wait) and returns the dropped names. With dry the file is left alone.

func RecordFailure

func RecordFailure(dir string) error

RecordFailure: one record per 75 after BEGIN (spec 8.3 breaker).

Types

type Ledger

type Ledger struct{ Dir string }

Ledger is ACCOUNT/remote/<type>/ledger.jsonl (spec 8.3): launch, begin, end lines.

func (Ledger) Begin

func (l Ledger) Begin(name string) error

func (Ledger) End

func (l Ledger) End(name string, minutes int, est, cost config.Micros, outcome string, created bool) error

func (Ledger) Launch

func (l Ledger) Launch(name string, est config.Micros) error

Jump to

Keyboard shortcuts

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