Documentation
¶
Overview ¶
Package bolt provides an bolt-backed store implementation.
The data stored in bolt is structured as follows:
bucket(/tasks/v1/tasks) key(:task_id) -> Content of submitted task (i.e. flux code). bucket(/tasks/v1/task_meta) key(:task_id) -> Protocol Buffer encoded backend.StoreTaskMeta, so we have a consistent view of runs in progress and max concurrency. bucket(/tasks/v1/org_by_task_id) key(task_id) -> The organization ID (stored as encoded string) associated with given task. bucket(/tasks/v1/user_by_task_id) key(:task_id) -> The user ID (stored as encoded string) associated with given task. buket(/tasks/v1/name_by_task_id) key(:task_id) -> The user-supplied name of the script. bucket(/tasks/v1/run_ids) -> Counter for run IDs bucket(/tasks/v1/orgs).bucket(:org_id) key(:task_id) -> Empty content; presence of :task_id allows for lookup from org to tasks. bucket(/tasks/v1/users).bucket(:user_id) key(:task_id) -> Empty content; presence of :task_id allows for lookup from user to tasks.
Note that task IDs are stored big-endian uint64s for sorting purposes, but presented to the users with leading 0-bytes stripped. Like other components of the system, IDs presented to users may be `0f12` rather than `f12`.
Index ¶
- Variables
- type Store
- func (s *Store) Close() error
- func (s *Store) CreateNextRun(ctx context.Context, taskID platform.ID, now int64) (backend.RunCreation, error)
- func (s *Store) CreateTask(ctx context.Context, req backend.CreateTaskRequest) (platform.ID, error)
- func (s *Store) DeleteOrg(ctx context.Context, id platform.ID) error
- func (s *Store) DeleteTask(ctx context.Context, id platform.ID) (deleted bool, err error)
- func (s *Store) DeleteUser(ctx context.Context, id platform.ID) error
- func (s *Store) FindTaskByID(ctx context.Context, id platform.ID) (*backend.StoreTask, error)
- func (s *Store) FindTaskByIDWithMeta(ctx context.Context, id platform.ID) (*backend.StoreTask, *backend.StoreTaskMeta, error)
- func (s *Store) FindTaskMetaByID(ctx context.Context, id platform.ID) (*backend.StoreTaskMeta, error)
- func (s *Store) FinishRun(ctx context.Context, taskID, runID platform.ID) error
- func (s *Store) ListTasks(ctx context.Context, params backend.TaskSearchParams) ([]backend.StoreTaskWithMeta, error)
- func (s *Store) ManuallyRunTimeRange(_ context.Context, taskID platform.ID, start, end, requestedAt int64) (*backend.StoreTaskMetaManualRun, error)
- func (s *Store) UpdateTask(ctx context.Context, req backend.UpdateTaskRequest) (backend.UpdateTaskResult, error)
Constants ¶
This section is empty.
Variables ¶
var ErrDBReadOnly = errors.New("db is read only")
ErrDBReadOnly is an error for when the database is set to read only. Tasks needs to be able to write to the db.
var ErrMaxConcurrency = errors.New("max concurrency reached")
ErrMaxConcurrency is an error for when the max concurrency is already reached for a task when you try to schedule a task.
var ErrNotFound = errors.New("task not found")
ErrNotFound is an error for when a task could not be found
var ErrRunNotFound = errors.New("run not found")
ErrRunNotFound is an error for when a run isn't found in a FinishRun method.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is task store for bolt.
func (*Store) CreateNextRun ¶
func (*Store) CreateTask ¶
CreateTask creates a task in the boltdb task store.
func (*Store) DeleteOrg ¶
DeleteOrg syncronously deletes an org and all their tasks from a bolt store.
func (*Store) DeleteTask ¶
DeleteTask deletes the task.
func (*Store) DeleteUser ¶
DeleteUser syncronously deletes a user and all their tasks from a bolt store.
func (*Store) FindTaskByID ¶
FindTaskByID finds a task with a given an ID. It will return nil if the task does not exist.
func (*Store) FindTaskByIDWithMeta ¶
func (*Store) FindTaskMetaByID ¶
func (*Store) FinishRun ¶
FinishRun removes runID from the list of running tasks and if its `now` is later then last completed update it.
func (*Store) ListTasks ¶
func (s *Store) ListTasks(ctx context.Context, params backend.TaskSearchParams) ([]backend.StoreTaskWithMeta, error)
ListTasks lists the tasks based on a filter.
func (*Store) ManuallyRunTimeRange ¶
func (*Store) UpdateTask ¶
func (s *Store) UpdateTask(ctx context.Context, req backend.UpdateTaskRequest) (backend.UpdateTaskResult, error)