tasks

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	NewTaskHandler(timeout time.Duration, retryDelay time.Duration, t Task) TaskHandler
	WaitForTasks()
}

Manager describtes the basic functionality of a task Manager

func NewManager

func NewManager(logger *logrus.Logger) Manager

NewManager creates a new Manager

type ManagerDetails

type ManagerDetails struct {
	// contains filtered or unexported fields
}

ManagerDetails contains information required for implmentation of task Manager

func (*ManagerDetails) NewTaskHandler

func (md *ManagerDetails) NewTaskHandler(
	timeout time.Duration, retryDelay time.Duration, task Task) TaskHandler

NewTaskHandler creates a new task handler, where each phase can take upto 'timeout' duration and there is a delay of 'retryDelay' before a retry.

func (*ManagerDetails) WaitForTasks

func (md *ManagerDetails) WaitForTasks()

WaitForTasks blocks until all tasks associated withis Manager have completed

type SnapshotTask

type SnapshotTask struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SnapshotTask pushes a snapshot to Ethereum

func NewSnapshotTask

func NewSnapshotTask(logger *logrus.Logger, eth blockchain.Ethereum, acct accounts.Account, epoch *big.Int, rawBclaims []byte, rawSigGroup []byte) *SnapshotTask

NewSnapshotTask creates a new task

func (*SnapshotTask) DoDone

func (t *SnapshotTask) DoDone()

DoDone creates a log entry saying task is complete

func (*SnapshotTask) DoRetry

func (t *SnapshotTask) DoRetry(ctx context.Context) bool

DoRetry is subsequent attempts at distributing shares via ethdkg

func (*SnapshotTask) DoWork

func (t *SnapshotTask) DoWork(ctx context.Context) bool

DoWork is the first attempt at distributing shares via ethdkg

func (*SnapshotTask) ShouldRetry

func (t *SnapshotTask) ShouldRetry(ctx context.Context) bool

ShouldRetry checks if it makes sense to try again

type Task

type Task interface {
	DoDone()
	DoRetry(context.Context) bool
	DoWork(context.Context) bool
	ShouldRetry(context.Context) bool
}

Task the interface requirements of a task

type TaskDoFunc

type TaskDoFunc func(context.Context) bool

TaskDoFunc is shorthand for func(context.Context) bool, which is what the Do*() task functions are -- Return value indicates if task work has completed succesfully

type TaskDoneFunc

type TaskDoneFunc func()

TaskDoneFunc is shorthand for func() bool, which is the DoDone() type -- This is executed as a cleanup, so can't be canceled

type TaskHandler

type TaskHandler interface {
	Cancel()
	Start()
	Complete() bool
	Successful() bool
}

TaskHandler required functionality of a task

type TaskHandlerDetails

type TaskHandlerDetails struct {
	ID int
	// contains filtered or unexported fields
}

TaskHandlerDetails contains all the data required to implment a task

func (*TaskHandlerDetails) Cancel

func (td *TaskHandlerDetails) Cancel()

Cancel stops the task's goroutine

func (*TaskHandlerDetails) Complete

func (td *TaskHandlerDetails) Complete() bool

Complete returns indication of whether has completed

func (*TaskHandlerDetails) Start

func (td *TaskHandlerDetails) Start()

Start begins orchestrating the task in a goroutine

func (*TaskHandlerDetails) Successful

func (td *TaskHandlerDetails) Successful() bool

Successful returns indication of whether the task was eventually successful

type TaskShouldFunc

type TaskShouldFunc func(context.Context) bool

TaskShouldFunc is shorthand for func(context.Context) bool, which is the ShouldRetry() type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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