taskmanager

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

ss-taskmanager

Async task manager. Tasks can easily be customized and executed asynchronously on the next available worker.

The manager keeps workers ready to multiplex tasks. The maximum no. of workers can be configured.

This package was mainly created to abstract all async functionality from the app. It provides a consistent context interface to manage routine lifecycle from a single place.

Install

ss-taskmanager works like a regular Go module:

> go get github.com/SWRMLabs/ss-taskmanager

Usage

import "github.com/SWRMLabs/ss-taskmanager"

Check tests for examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorListener

type ErrorListener interface {
	HandleError()
}

type RestartableTask

type RestartableTask interface {
	Restart(context.Context)
}

type Task

type Task interface {
	Execute(context.Context) error
	Name() string
}

type TaskManager

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

func NewTaskManager

func NewTaskManager(parentContext context.Context,
	maxWorkerCount int32) *TaskManager

func (*TaskManager) GoWork

func (m *TaskManager) GoWork(newTask Task)

func (*TaskManager) Status

func (m *TaskManager) Status() map[int32]*WorkerInfo

func (*TaskManager) Stop

func (m *TaskManager) Stop()

func (*TaskManager) TaskWithProgressStatus

func (m *TaskManager) TaskWithProgressStatus() map[string]TaskWithProgress

type TaskWithProgress

type TaskWithProgress interface {
	Pause()
	Progress() (float64, error)
	Description() string
	Name() string
}

type WorkerInfo

type WorkerInfo struct {
	TaskName string
	Status   string
}

Jump to

Keyboard shortcuts

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