Documentation ¶
Index ¶
- Variables
- type AtomicGroup
- type AtomicGroupKey
- type Command
- type Commander
- type ErrorCounter
- type FiniteCommand
- type FiniteCommandWithErrorCounter
- type Group
- type InfiniteCommand
- type MultiClientScheduler
- type QueuedAtomicGroup
- type ReplacementPolicy
- type Runner
- type Scheduler
- type SingleShotCommand
- type TaskType
Constants ¶
This section is empty.
Variables ¶
var ErrTaskOverwritten = errors.New("task overwritten")
Functions ¶
This section is empty.
Types ¶
type AtomicGroup ¶
type AtomicGroup struct {
// contains filtered or unexported fields
}
AtomicGroup terminates as soon as first goroutine terminates with error.
func NewAtomicGroup ¶
func NewAtomicGroup(parent context.Context) *AtomicGroup
func (*AtomicGroup) Add ¶
func (d *AtomicGroup) Add(cmd Command)
Go spawns function in a goroutine and stores results or errors.
func (*AtomicGroup) Error ¶
func (d *AtomicGroup) Error() error
Error stores an error that was reported by any of the downloader. Should be called after Wait.
func (*AtomicGroup) Name ¶ added in v0.172.10
func (d *AtomicGroup) Name() string
func (*AtomicGroup) SetName ¶ added in v0.172.10
func (d *AtomicGroup) SetName(name string)
func (*AtomicGroup) Stop ¶
func (d *AtomicGroup) Stop()
func (*AtomicGroup) WaitAsync ¶
func (d *AtomicGroup) WaitAsync() <-chan struct{}
type AtomicGroupKey ¶ added in v0.172.10
type AtomicGroupKey string
type ErrorCounter ¶ added in v0.172.10
type ErrorCounter struct {
// contains filtered or unexported fields
}
func NewErrorCounter ¶ added in v0.172.10
func NewErrorCounter(maxErrors int, msg string) *ErrorCounter
func (*ErrorCounter) Error ¶ added in v0.172.10
func (ec *ErrorCounter) Error() error
func (*ErrorCounter) MaxErrors ¶ added in v0.172.10
func (ec *ErrorCounter) MaxErrors() int
func (*ErrorCounter) SetError ¶ added in v0.172.10
func (ec *ErrorCounter) SetError(err error) bool
Returns false in case of counter overflow
type FiniteCommand ¶
FiniteCommand terminates when error is nil.
type FiniteCommandWithErrorCounter ¶ added in v0.172.10
type FiniteCommandWithErrorCounter struct { FiniteCommand *ErrorCounter }
type InfiniteCommand ¶
InfiniteCommand runs until context is closed.
type MultiClientScheduler ¶ added in v0.163.14
type MultiClientScheduler struct {
// contains filtered or unexported fields
}
func NewMultiClientScheduler ¶ added in v0.163.14
func NewMultiClientScheduler() *MultiClientScheduler
func (*MultiClientScheduler) Enqueue ¶ added in v0.163.14
func (s *MultiClientScheduler) Enqueue(requestID int32, taskType TaskType, taskFn taskFunction, resFn resultFunction) (ignored bool)
func (*MultiClientScheduler) Stop ¶ added in v0.163.14
func (s *MultiClientScheduler) Stop()
type QueuedAtomicGroup ¶ added in v0.148.4
type QueuedAtomicGroup struct { *AtomicGroup // contains filtered or unexported fields }
func NewQueuedAtomicGroup ¶ added in v0.148.4
func NewQueuedAtomicGroup(parent context.Context, limit uint32) *QueuedAtomicGroup
func (*QueuedAtomicGroup) Add ¶ added in v0.148.4
func (d *QueuedAtomicGroup) Add(cmd Command)
type ReplacementPolicy ¶ added in v0.162.13
type ReplacementPolicy = int
const ( // ReplacementPolicyCancelOld for when the task arguments might change the result ReplacementPolicyCancelOld ReplacementPolicy = iota // ReplacementPolicyIgnoreNew for when the task arguments doesn't change the result ReplacementPolicyIgnoreNew )
type Scheduler ¶ added in v0.162.13
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶ added in v0.162.13
func NewScheduler() *Scheduler
func (*Scheduler) Enqueue ¶ added in v0.162.13
func (s *Scheduler) Enqueue(taskType TaskType, taskFn taskFunction, resFn resultFunction) (ignored bool)
Enqueue provides a queue of task types allowing only one task at a time of the corresponding type. The running task is the first one in the queue (s.queue.Oldest())
Schedule policy for new tasks
- pushed at the back of the queue (s.queue.PushBack()) if none of the same time already scheduled
- overwrite the queued one of the same type, depending on the policy
- In case of ReplacementPolicyIgnoreNew, the new task will be ignored
- In case of ReplacementPolicyCancelOld, the old running task will be canceled or if not yet run overwritten and the new one will be executed when its turn comes.
The task function (taskFn) might not be executed if
- the task is ignored
- the task is overwritten. The result function (resFn) will be called with ErrTaskOverwritten
The result function (resFn) will always be called if the task is not ignored
type SingleShotCommand ¶ added in v0.170.0
type SingleShotCommand struct { Interval time.Duration Init func(context.Context) error Runable func(context.Context) error }
SingleShotCommand runs once.
type TaskType ¶ added in v0.162.13
type TaskType struct { ID int64 Policy ReplacementPolicy }