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
- Variables
- func FixDatabase() error
- func Init(db *gorm.DB) error
- func Name() string
- func ReplayCreate(replay *models.SReplay) error
- func ReplayList(offset, limit int64) ([]models.SReplay, int64, error)
- func SQLiteDSN(dsn string) string
- func TaskCount(state models.State) int64
- func TaskCreate(task *models.STask) error
- func TaskList(page, pageSize int64, prefix string) (models.STasks, int64)
- type EnvStore
- type LogStore
- type StepStore
- func (s *StepStore) ClearAll() error
- func (s *StepStore) Content() (res string, err error)
- func (s *StepStore) Env() *EnvStore
- func (s *StepStore) Get() (res *models.SStep, err error)
- func (s *StepStore) GlobalEnv() *EnvStore
- func (s *StepStore) Kind() (res string, err error)
- func (s *StepStore) Log() *LogStore
- func (s *StepStore) Name() string
- func (s *StepStore) Options() (res iproto.SStepOptions, err error)
- func (s *StepStore) Remove() error
- func (s *StepStore) RetryPolicy() (res *iproto.SRetryPolicy, err error)
- func (s *StepStore) State() (state models.State, err error)
- func (s *StepStore) TaskName() string
- func (s *StepStore) Timeout() (res time.Duration, err error)
- func (s *StepStore) Update(value *models.SStepUpdate) (err error)
- type Store
- func (d *Store) FixDatabase() error
- func (d *Store) Name() string
- func (d *Store) ReplayCreate(replay *models.SReplay) error
- func (d *Store) ReplayGet(id string) (row models.SReplay, err error)
- func (d *Store) ReplayImport(rows []models.SReplay) error
- func (d *Store) ReplayList(offset, limit int64) ([]models.SReplay, int64, error)
- func (d *Store) Task(name string) *TaskStore
- func (d *Store) TaskCount(state models.State) (res int64)
- func (d *Store) TaskCreate(task *models.STask) (err error)
- func (d *Store) TaskList(page, pageSize int64, str string) (res models.STasks, total int64)
- type TaskStore
- func (t *TaskStore) ClearAll() error
- func (t *TaskStore) Env() *EnvStore
- func (t *TaskStore) Get() (res *models.STask, err error)
- func (t *TaskStore) Name() string
- func (t *TaskStore) Remove() error
- func (t *TaskStore) State() (state models.State, err error)
- func (t *TaskStore) Step(name string) *StepStore
- func (t *TaskStore) StepCount() (res int64)
- func (t *TaskStore) StepCreate(step *models.SStep) error
- func (t *TaskStore) StepFor(row *models.SStep) *StepStore
- func (t *TaskStore) StepList(str string) (res models.SSteps)
- func (t *TaskStore) StepNameList(str string) (res []string)
- func (t *TaskStore) StepStateList(str string) (res map[string]models.State)
- func (t *TaskStore) Timeout() (res time.Duration, err error)
- func (t *TaskStore) Update(value *models.STaskUpdate) (err error)
- func (t *TaskStore) Workspace(ctx context.Context) (string, error)
Constants ¶
const All = ""
All selects all names when a method accepts a name filter.
Variables ¶
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 ¶
Init installs a default store only after initialization succeeds. Existing handles retain their original database; this function does not close it.
func ReplayCreate ¶
func SQLiteDSN ¶
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 TaskCreate ¶
TaskCreate inserts a task into the default store.
Types ¶
type EnvStore ¶
type EnvStore struct {
// contains filtered or unexported fields
}
EnvStore persists environment variables within a task or step scope.
type LogStore ¶
type LogStore struct {
// contains filtered or unexported fields
}
LogStore persists output for one step and supports incremental reads.
type StepStore ¶
type StepStore struct {
// contains filtered or unexported fields
}
StepStore scopes persistence operations to one step within a task.
func (*StepStore) RetryPolicy ¶
func (s *StepStore) RetryPolicy() (res *iproto.SRetryPolicy, 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 ¶
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 ¶
FixDatabase recovers interrupted work. The caller must exclusively own the database.
func (*Store) ReplayList ¶
type TaskStore ¶
type TaskStore struct {
// contains filtered or unexported fields
}
TaskStore scopes persistence operations to one task name.