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 ¶
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.
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 NewCron ¶
NewCron is returning a Helper that will execute the task according to the schedule. cronSchedule is following the standard syntax described here: https://en.wikipedia.org/wiki/Cron. It also supports the predefined scheduling definitions: - @yearly (or @annually) | Run once a year, midnight, Jan. 1st | 0 0 0 1 1 * - @monthly | Run once a month, midnight, first of month | 0 0 0 1 * * - @weekly | Run once a week, midnight between Sat/Sun | 0 0 0 * * 0 - @daily (or @midnight) | Run once a day, midnight | 0 0 0 * * * - @hourly | Run once an hour, beginning of hour | 0 0 * * * *
We are directly relying on what the library https://pkg.go.dev/github.com/robfig/cron is supporting.