storage

package
v0.0.0-...-2fa33bc Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 15 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 storage provides task persistence backed by GORM. New constructs an independent store; Init installs the default store used by package helpers. The caller owns and closes the underlying database connection.

Index

Constants

View Source
const All = ""

All selects all names when a method accepts a name filter.

Variables

View Source
var ErrTaskNotFound = errors.New("task does not exist")

ErrTaskNotFound indicates that no persisted task has the requested name.

Functions

func FixDatabase

func FixDatabase() error

FixDatabase recovers interrupted work under exclusive database ownership.

func Init

func Init(db *gorm.DB) error

Init installs a default store only after initialization succeeds. Existing handles retain their original database; this function does not close it.

func Name

func Name() string

Name returns the default store's database dialect.

func ReplayCreate

func ReplayCreate(replay *models.SReplay) error

func ReplayList

func ReplayList(offset, limit int64) ([]models.SReplay, int64, error)

func SQLiteDSN

func SQLiteDSN(dsn string) string

SQLiteDSN adds the application's SQLite tuning defaults for the modernc driver. It leaves URI options such as mode/cache intact. Explicit tuning in the supplied DSN takes precedence; use xsqlite.Open to also apply its foreign-key and time handling defaults.

func TaskCount

func TaskCount(state models.State) int64

TaskCount counts tasks in the specified state.

func TaskCreate

func TaskCreate(task *models.STask) error

TaskCreate inserts a task into the default store.

func TaskList

func TaskList(page, pageSize int64, prefix string) (models.STasks, int64)

TaskList lists tasks using the default store.

Types

type EnvStore

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

EnvStore persists environment variables within a task or step scope.

func (*EnvStore) Get

func (e *EnvStore) Get(name string) (res string, err error)

func (*EnvStore) Insert

func (e *EnvStore) Insert(envs ...*models.SEnv) error

func (*EnvStore) List

func (e *EnvStore) List() (res models.SEnvs)

func (*EnvStore) Remove

func (e *EnvStore) Remove(name string) error

func (*EnvStore) RemoveAll

func (e *EnvStore) RemoveAll() error

func (*EnvStore) Update

func (e *EnvStore) Update(env *models.SEnv) error

type LogStore

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

LogStore persists output for one step and supports incremental reads.

func (*LogStore) Insert

func (l *LogStore) Insert(log *models.SStepLog) error

func (*LogStore) List

func (l *LogStore) List(latestLine *int64) (res models.SStepLogs)

func (*LogStore) RemoveAll

func (l *LogStore) RemoveAll() error

func (*LogStore) Write

func (l *LogStore) Write(contents ...string)

func (*LogStore) Writef

func (l *LogStore) Writef(format string, args ...any)

type StepStore

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

StepStore scopes persistence operations to one step within a task.

func (*StepStore) ClearAll

func (s *StepStore) ClearAll() error

func (*StepStore) Content

func (s *StepStore) Content() (res string, err error)

func (*StepStore) Env

func (s *StepStore) Env() *EnvStore

func (*StepStore) Get

func (s *StepStore) Get() (res *models.SStep, err error)

func (*StepStore) GlobalEnv

func (s *StepStore) GlobalEnv() *EnvStore

func (*StepStore) Kind

func (s *StepStore) Kind() (res string, err error)

func (*StepStore) Log

func (s *StepStore) Log() *LogStore

func (*StepStore) Name

func (s *StepStore) Name() string

func (*StepStore) Options

func (s *StepStore) Options() (res iproto.SStepOptions, err error)

func (*StepStore) Remove

func (s *StepStore) Remove() error

func (*StepStore) RetryPolicy

func (s *StepStore) RetryPolicy() (res *iproto.SRetryPolicy, err error)

func (*StepStore) State

func (s *StepStore) State() (state models.State, err error)

func (*StepStore) TaskName

func (s *StepStore) TaskName() string

func (*StepStore) Timeout

func (s *StepStore) Timeout() (res time.Duration, err error)

func (*StepStore) Update

func (s *StepStore) Update(value *models.SStepUpdate) (err error)

type Store

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

Store provides database-level operations and scoped persistence handles.

func Default

func Default() *Store

Default returns the initialized package store. Applications using the package helpers must call Init first; independently constructed stores do not need it.

func New

func New(db *gorm.DB) (*Store, error)

New initializes and migrates a store without changing the package default. SQLite pools must enable foreign keys on every connection before use, as xsqlite.Open does by default. New does not modify connection settings.

func (*Store) FixDatabase

func (d *Store) FixDatabase() error

FixDatabase recovers interrupted work. The caller must exclusively own the database.

func (*Store) Name

func (d *Store) Name() string

func (*Store) ReplayCreate

func (d *Store) ReplayCreate(replay *models.SReplay) error

func (*Store) ReplayGet

func (d *Store) ReplayGet(id string) (row models.SReplay, err error)

func (*Store) ReplayImport

func (d *Store) ReplayImport(rows []models.SReplay) error

func (*Store) ReplayList

func (d *Store) ReplayList(offset, limit int64) ([]models.SReplay, int64, error)

func (*Store) Task

func (d *Store) Task(name string) *TaskStore

func (*Store) TaskCount

func (d *Store) TaskCount(state models.State) (res int64)

func (*Store) TaskCreate

func (d *Store) TaskCreate(task *models.STask) (err error)

func (*Store) TaskList

func (d *Store) TaskList(page, pageSize int64, str string) (res models.STasks, total int64)

type TaskStore

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

TaskStore scopes persistence operations to one task name.

func Task

func Task(name string) *TaskStore

Task returns a task-scoped handle from the default store.

func (*TaskStore) ClearAll

func (t *TaskStore) ClearAll() error

func (*TaskStore) Env

func (t *TaskStore) Env() *EnvStore

func (*TaskStore) Get

func (t *TaskStore) Get() (res *models.STask, err error)

func (*TaskStore) Name

func (t *TaskStore) Name() string

func (*TaskStore) Remove

func (t *TaskStore) Remove() error

func (*TaskStore) State

func (t *TaskStore) State() (state models.State, err error)

func (*TaskStore) Step

func (t *TaskStore) Step(name string) *StepStore

func (*TaskStore) StepCount

func (t *TaskStore) StepCount() (res int64)

func (*TaskStore) StepCreate

func (t *TaskStore) StepCreate(step *models.SStep) error

func (*TaskStore) StepFor

func (t *TaskStore) StepFor(row *models.SStep) *StepStore

func (*TaskStore) StepList

func (t *TaskStore) StepList(str string) (res models.SSteps)

func (*TaskStore) StepNameList

func (t *TaskStore) StepNameList(str string) (res []string)

func (*TaskStore) StepStateList

func (t *TaskStore) StepStateList(str string) (res map[string]models.State)

func (*TaskStore) Timeout

func (t *TaskStore) Timeout() (res time.Duration, err error)

func (*TaskStore) Update

func (t *TaskStore) Update(value *models.STaskUpdate) (err error)

func (*TaskStore) Workspace

func (t *TaskStore) Workspace(ctx context.Context) (string, error)

Workspace returns the task's persisted relative workdir, not its API name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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