once

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const MaxKeyLen = 256

Variables

View Source
var (
	ErrConflict = errors.New("record conflicts with existing key")
	ErrNotFound = errors.New("record not found")
	ErrRunning  = errors.New("record is still running")
)

Functions

func CheckSQLiteSchemaVersion added in v0.6.0

func CheckSQLiteSchemaVersion(version string) error

CheckSQLiteSchemaVersion rejects stores that need a different once binary.

func HashAttemptToken

func HashAttemptToken(token string) string

func NewAttemptToken

func NewAttemptToken() (string, error)

func RejectSharedWritableParent added in v0.5.0

func RejectSharedWritableParent(path string) error

func RejectSymlinkPath

func RejectSymlinkPath(path string) error

func RestrictLocalFile

func RestrictLocalFile(path string) error

func ValidateAttemptToken

func ValidateAttemptToken(token string) error

func ValidateKey

func ValidateKey(key string) error

func ValidateSQLitePath added in v0.2.2

func ValidateSQLitePath(path string) error

ValidateSQLitePath rejects SQLite DSN forms. once stores must be local filesystem paths so SQLite options cannot bypass local file checks.

Types

type ListOptions added in v0.2.0

type ListOptions struct {
	State         State
	Limit         int
	IncludeOutput bool
	UpdatedBefore time.Time
}

type PruneOptions added in v0.2.1

type PruneOptions struct {
	State  State
	Cutoff time.Time
	Force  bool
}

type PruneResult added in v0.2.1

type PruneResult struct {
	Records []Record
	Deleted int
}

type Record

type Record struct {
	Key        string
	Attempt    string
	State      State
	ExitCode   int
	Stdout     []byte
	Stderr     []byte
	Error      string
	Command    []string
	StartedAt  time.Time
	FinishedAt *time.Time
	UpdatedAt  time.Time
}

type SQLiteStore

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

func OpenSQLite

func OpenSQLite(path string) (*SQLiteStore, error)

func (*SQLiteStore) AdminForget

func (s *SQLiteStore) AdminForget(key string, force bool) (bool, error)

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) Commit

func (s *SQLiteStore) Commit(key, attempt string, state State, exitCode int, stdout, stderr []byte, runErr string) (Record, error)

func (*SQLiteStore) Forget

func (s *SQLiteStore) Forget(key string, force bool, attempt string) (bool, error)

func (*SQLiteStore) Get

func (s *SQLiteStore) Get(key string) (Record, error)

func (*SQLiteStore) List added in v0.2.0

func (s *SQLiteStore) List(opts ListOptions) ([]Record, error)

func (*SQLiteStore) Prune added in v0.2.1

func (s *SQLiteStore) Prune(opts PruneOptions) (PruneResult, error)

func (*SQLiteStore) Reserve

func (s *SQLiteStore) Reserve(key string, command []string) (Record, bool, error)

type State

type State string
const (
	Running   State = "running"
	Succeeded State = "succeeded"
	Failed    State = "failed"
)

type Store

type Store interface {
	Close() error
	Reserve(key string, command []string) (Record, bool, error)
	Commit(key, attempt string, state State, exitCode int, stdout, stderr []byte, runErr string) (Record, error)
	Get(key string) (Record, error)
	Forget(key string, force bool, attempt string) (bool, error)
}

Jump to

Keyboard shortcuts

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