Documentation
¶
Overview ¶
Package executor provides an implementation of the Executor to perform background processing, limiting resource consumption when executing a collection of jobs.
Executor example:
exe := executor.New(10)
defer exe.Shutdown()
for i := 0; i < 100; i++ {
idx := i
err := exe.Schedule(func(ctx context.Context) {
select {
case <-ctx.Done():
log.Printf("[JOB] ID %d - stop \n", idx)
return
default:
log.Printf("[JOB] ID %d \n", idx)
time.Sleep(time.Millisecond * 100)
})
if err != nil {
t.Log(err)
break
}
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor contains logic for goroutine execution.
func New ¶
New returns an initialized goroutine executor.
The size parameter determines the limit of the executor.
func (*Executor) IsTerminated ¶
IsTerminated return if the executor is terminated.
Click to show internal directories.
Click to hide internal directories.