Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrorTimeOut = fmt.Errorf("TimeOut")
ErrorTimeOut is the error when executes tasks timeout
var ( // ErrorUsingActuator is the error when goroutine pool has exception ErrorUsingActuator = fmt.Errorf("ErrorUsingActuator") )
Functions ¶
func DurationPtr ¶
DurationPtr helps to make a duration ptr
func Exec ¶
Exec simply runs the tasks concurrently True will be returned is all tasks complete successfully otherwise false will be returned
func ExecWithError ¶
ExecWithError simply runs the tasks concurrently nil will be returned is all tasks complete successfully otherwise custom error will be returned
Types ¶
type Actuator ¶
type Actuator struct {
// contains filtered or unexported fields
}
Actuator is the base struct
func NewActuator ¶
NewActuator creates an Actuator instance
func (*Actuator) ExecWithContext ¶
ExecWithContext is used to run tasks concurrently Return nil when tasks are all completed successfully, or return error when some exception happen such as timeout
func (*Actuator) GetTimeout ¶
GetTimeout return the timeout set before
type BaseActuator ¶
type BaseActuator interface { Exec(tasks ...Task) error ExecWithContext(ctx context.Context, tasks ...Task) error }
BaseActuator is the actuator interface
type GoroutinePool ¶
type GoroutinePool interface { Submit(f func()) error Release() }
GoroutinePool is the base routine pool interface User can use custom goroutine pool by implementing this interface
type PooledActuator ¶
type PooledActuator struct {
// contains filtered or unexported fields
}
PooledActuator is a actuator which has a worker pool
func NewPooledActuator ¶
func NewPooledActuator(workerNum int, opt ...*Options) *PooledActuator
NewPooledActuator creates an PooledActuator instance
func (*PooledActuator) Exec ¶
func (c *PooledActuator) Exec(tasks ...Task) error
Exec is used to run tasks concurrently
func (*PooledActuator) ExecWithContext ¶
func (c *PooledActuator) ExecWithContext(ctx context.Context, tasks ...Task) error
ExecWithContext uses goroutine pool to run tasks concurrently Return nil when tasks are all completed successfully, or return error when some exception happen such as timeout
func (*PooledActuator) GetTimeout ¶
func (c *PooledActuator) GetTimeout() *time.Duration
GetTimeout return the timeout set before
func (*PooledActuator) WithPool ¶
func (c *PooledActuator) WithPool(pool GoroutinePool) *PooledActuator
WithPool will support for using custom goroutine pool
type TimedActuator ¶
type TimedActuator interface { BaseActuator GetTimeout() *time.Duration // contains filtered or unexported methods }
TimedActuator is the actuator interface within timeout method