taskhelper

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package taskhelper provides struct and methods to help to synchronize different async.Task together and to simply start the async.Task properly This package should mainly used through the package app and not directly by the developer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinAll

func JoinAll(ctx context.Context, timeout time.Duration, helpers []Helper)

JoinAll is waiting for context to be canceled. A task that is ended and should stop the whole application, must have called the master cancelFunc shared by every TaskRunner which will closed the master context.

func Run

func Run(ctx context.Context, cancelFunc context.CancelFunc, t Helper)

Run is executing in a go-routing the Helper that handles a unique task

Types

type Helper

type Helper interface {
	fmt.Stringer
	Start(ctx context.Context, cancelFunc context.CancelFunc) error
	// Done returns the channel used to wait for the task job to be finalized
	Done() <-chan struct{}
}

Helper is an interface that defines a wrapper of the task that would help to execute it. Even if this interface is public, you usually don't have to implement it yourself, you just have to implement a Task or a SimpleTask

func New

func New(task interface{}) (Helper, error)

func NewCron

func NewCron(task interface{}, interval time.Duration) (Helper, error)

NewCron is returning a Helper that will execute the task periodically. The task can be a SimpleTask or a Task. It returns an error if it's something different

Jump to

Keyboard shortcuts

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