bolt

package
v0.0.0-...-d500d3c Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

View Source
var ErrNotFound = errors.New("task not found")

ErrNotFound is an error for when a task could not be found

View Source
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 New

func New(db *bolt.DB, rootBucket string) (*Store, error)

New gives us a new Store based on "github.com/coreos/bbolt"

func (*Store) Close

func (s *Store) Close() error

Close closes the store

func (*Store) CreateNextRun

func (s *Store) CreateNextRun(ctx context.Context, taskID platform.ID, now int64) (backend.RunCreation, error)

func (*Store) CreateTask

func (s *Store) CreateTask(ctx context.Context, req backend.CreateTaskRequest) (platform.ID, error)

CreateTask creates a task in the boltdb task store.

func (*Store) DeleteOrg

func (s *Store) DeleteOrg(ctx context.Context, id platform.ID) error

DeleteOrg syncronously deletes an org and all their tasks from a bolt store.

func (*Store) DeleteTask

func (s *Store) DeleteTask(ctx context.Context, id platform.ID) (deleted bool, err error)

DeleteTask deletes the task.

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, id platform.ID) error

DeleteUser syncronously deletes a user and all their tasks from a bolt store.

func (*Store) FindTaskByID

func (s *Store) FindTaskByID(ctx context.Context, id platform.ID) (*backend.StoreTask, error)

FindTaskByID finds a task with a given an ID. It will return nil if the task does not exist.

func (*Store) FindTaskByIDWithMeta

func (s *Store) FindTaskByIDWithMeta(ctx context.Context, id platform.ID) (*backend.StoreTask, *backend.StoreTaskMeta, error)

func (*Store) FindTaskMetaByID

func (s *Store) FindTaskMetaByID(ctx context.Context, id platform.ID) (*backend.StoreTaskMeta, error)

func (*Store) FinishRun

func (s *Store) FinishRun(ctx context.Context, taskID, runID platform.ID) error

FinishRun removes runID from the list of running tasks and if its `now` is later then last completed update it.

func (*Store) ListTasks

ListTasks lists the tasks based on a filter.

func (*Store) ManuallyRunTimeRange

func (s *Store) ManuallyRunTimeRange(_ context.Context, taskID platform.ID, start, end, requestedAt int64) (*backend.StoreTaskMetaManualRun, error)

func (*Store) UpdateTask

Jump to

Keyboard shortcuts

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