tasks_manager

package
v0.0.0-...-6aa8790 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBusy            = errors.New("busy")
	ErrContextCanceled = errors.New("context canceled")
)

Functions

This section is empty.

Types

type ActionsInterface

type ActionsInterface interface {
	// RunTask runs task or returns busy error
	RunTask(ctx context.Context, reqStorage logical.Storage, taskFunc func(ctx context.Context, storage logical.Storage) error) (string, error)

	// AddTask adds task to queue
	AddTask(ctx context.Context, reqStorage logical.Storage, taskFunc func(ctx context.Context, storage logical.Storage) error) (string, error)

	// AddOptionalTask adds task to queue if empty
	AddOptionalTask(ctx context.Context, reqStorage logical.Storage, taskFunc func(ctx context.Context, storage logical.Storage) error) (string, bool, error)
}

type Manager

type Manager struct {
	Storage logical.Storage
	Worker  worker.Interface
	// contains filtered or unexported fields
}

func NewManager

func NewManager(logger hclog.Logger) *Manager

func (*Manager) AddOptionalTask

func (m *Manager) AddOptionalTask(ctx context.Context, reqStorage logical.Storage, taskFunc func(context.Context, logical.Storage) error) (string, bool, error)

func (*Manager) AddTask

func (m *Manager) AddTask(ctx context.Context, reqStorage logical.Storage, taskFunc func(context.Context, logical.Storage) error) (string, error)

func (*Manager) Paths

func (m *Manager) Paths() []*framework.Path

func (*Manager) PeriodicFunc

func (m *Manager) PeriodicFunc(ctx context.Context, req *logical.Request) error

func (*Manager) RunTask

func (m *Manager) RunTask(ctx context.Context, reqStorage logical.Storage, taskFunc func(context.Context, logical.Storage) error) (string, error)

func (*Manager) TaskFailedCallback

func (m *Manager) TaskFailedCallback(ctx context.Context, uuid string, log []byte, taskErr error)

func (*Manager) TaskStartedCallback

func (m *Manager) TaskStartedCallback(ctx context.Context, uuid string)

func (*Manager) TaskSucceededCallback

func (m *Manager) TaskSucceededCallback(ctx context.Context, uuid string, log []byte)

func (*Manager) WrapTaskFunc

func (m *Manager) WrapTaskFunc(taskFunc func(context.Context, logical.Storage) error, taskTimeoutDuration time.Duration) func(ctx context.Context) error

WrapTaskFunc separates processing of the context and the taskFunc execution in the background

type Task

type Task struct {
	UUID     string    `structs:"uuid" json:"uuid"`
	Status   string    `structs:"status" json:"status"`
	Reason   string    `structs:"reason" json:"reason"`
	Created  time.Time `structs:"created" json:"created"`
	Modified time.Time `structs:"modified" json:"modified"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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