store

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: EUPL-1.2 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatePending   = "pending"
	StateRunning   = "active"
	StateCompleted = "complete"
	StateFailed    = "failed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxAttempts int `json:"max_attempts"`
	TimeoutSec  int `json:"timeout_sec"`
	// Max amount of concurrent jobs
	MaxJobCount int `json:"max_job_count"`
	BackoffMult int `json:"backoff_mult"`
	BackoffBase int `json:"backoff_base"`
}

type FileMeta

type FileMeta struct {
	Inode uint64
	Mode  uint32
	UID   uint32
	GID   uint32
}

FileMeta holds standard POSIX file attributes

type Job

type Job struct {
	ID      string
	State   string
	INode   int
	Command string
	// Command output on completion
	Output    []byte
	Attempts  int
	CreatedAt time.Time
	UpdatedAt time.Time
}

A single unit of work

type Store

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

func NewStore

func NewStore(filepath string) (*Store, error)

func (*Store) AttemptJob

func (s *Store) AttemptJob(id string) error

Picks up a pending job and moves it to 'active'.

func (*Store) Close

func (s *Store) Close() error

func (*Store) CompleteJob

func (s *Store) CompleteJob(id string, output []byte) error

func (*Store) CreateJob

func (s *Store) CreateJob(id string, command string) (*Job, error)

Adds a new job with the 'pending' state.

func (*Store) DeleteJob

func (s *Store) DeleteJob(id string) error

func (*Store) FailJob

func (s *Store) FailJob(id string) error

func (*Store) GetConfig

func (st *Store) GetConfig() (conf Config)

func (*Store) GetFileMeta

func (st *Store) GetFileMeta(inode uint64) (*FileMeta, error)

func (*Store) GetJob

func (s *Store) GetJob(id string) (*Job, error)

func (*Store) ListJobsByState

func (s *Store) ListJobsByState(state string) ([]Job, error)

func (*Store) PopulateConfig

func (st *Store) PopulateConfig()

func (*Store) ResetJob

func (s *Store) ResetJob(id string) error

func (*Store) RestartJob

func (s *Store) RestartJob(id string, output []byte) error

Moves a job back to 'pending'.

func (*Store) UpdateConfig

func (st *Store) UpdateConfig(conf Config) error

func (*Store) UpsertFileMeta

func (st *Store) UpsertFileMeta(meta FileMeta) error

func (*Store) WriteOutput

func (s *Store) WriteOutput(id string, output []byte) error

Jump to

Keyboard shortcuts

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