kv

package
v1.7.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type Option

type Option func(s *Service)

func WithClock

func WithClock(c clock.Clock) Option

type Service

type Service struct {
	IDGenerator platform.IDGenerator
	// contains filtered or unexported fields
}

func New

func New(kv StorageService, opts ...Option) *Service

func (*Service) AddRunLog

func (s *Service) AddRunLog(ctx context.Context, taskID, runID platform.ID, when time.Time, log string) error

AddRunLog adds a log line to the run.

func (*Service) CancelRun

func (s *Service) CancelRun(ctx context.Context, taskID, runID platform.ID) error

CancelRun cancels a currently running run.

func (*Service) Close

func (s *Service) Close() error

func (*Service) CreateRun

func (s *Service) CreateRun(ctx context.Context, taskID platform.ID, scheduledFor time.Time, runAt time.Time) (*taskmodel.Run, error)

CreateRun creates a run with a scheduledFor time as now.

func (*Service) CreateTask

func (s *Service) CreateTask(ctx context.Context, tc taskmodel.TaskCreate) (*taskmodel.Task, error)

CreateTask creates a new task. The owner of the task is inferred from the authorizer associated with ctx.

func (*Service) CurrentlyRunning

func (s *Service) CurrentlyRunning(ctx context.Context, taskID platform.ID) ([]*taskmodel.Run, error)

func (*Service) DeleteTask

func (s *Service) DeleteTask(ctx context.Context, id platform.ID) error

DeleteTask removes a task by ID and purges all associated data and scheduled runs.

func (*Service) FindLogs

func (s *Service) FindLogs(ctx context.Context, filter taskmodel.LogFilter) ([]*taskmodel.Log, int, error)

FindLogs returns logs for a run.

func (*Service) FindRunByID

func (s *Service) FindRunByID(ctx context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)

FindRunByID returns a single run.

func (*Service) FindRuns

func (s *Service) FindRuns(ctx context.Context, filter taskmodel.RunFilter) ([]*taskmodel.Run, int, error)

FindRuns returns a list of runs that match a filter and the total count of returned runs.

func (*Service) FindTaskByID

func (s *Service) FindTaskByID(ctx context.Context, id platform.ID) (*taskmodel.Task, error)

FindTaskByID returns a single task

func (*Service) FindTasks

func (s *Service) FindTasks(ctx context.Context, filter taskmodel.TaskFilter) ([]*taskmodel.Task, int, error)

FindTasks returns a list of tasks that match a filter (limit 100) and the total count of matching tasks.

func (*Service) FinishRun

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

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

func (*Service) ForceRun

func (s *Service) ForceRun(ctx context.Context, taskID platform.ID, scheduledFor int64) (*taskmodel.Run, error)

ForceRun forces a run to occur with unix timestamp scheduledFor, to be executed as soon as possible. The value of scheduledFor may or may not align with the task's schedule.

func (*Service) ManualRuns

func (s *Service) ManualRuns(ctx context.Context, taskID platform.ID) ([]*taskmodel.Run, error)

func (*Service) Open

func (s *Service) Open() error

func (*Service) RetryRun

func (s *Service) RetryRun(ctx context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)

RetryRun creates and returns a new run (which is a retry of another run).

func (*Service) StartManualRun

func (s *Service) StartManualRun(ctx context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)

func (*Service) UpdateRunState

func (s *Service) UpdateRunState(ctx context.Context, taskID, runID platform.ID, when time.Time, state taskmodel.RunStatus) error

UpdateRunState sets the run state at the respective time.

func (*Service) UpdateTask

func (s *Service) UpdateTask(ctx context.Context, id platform.ID, upd taskmodel.TaskUpdate) (*taskmodel.Task, error)

UpdateTask updates a single task with changeset.

type StorageService

type StorageService interface {
	Store(string) storage.Interface
}

Jump to

Keyboard shortcuts

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