Documentation
¶
Index ¶
- func GoID() int
- func Parallel(ctx context.Context, fn ...) (<-chan struct{}, func())
- func Peer[T any](c chans.Result[T], fn func(context.Context) (T, error)) peer[T]
- func SetDefaultContext(ctx context.Context)
- func SetGoPanicLogger(l interfaces.Logger)
- func Task[T any](task parallelJob[T]) peer[T]
- func TaskFunc[T any](fn func(context.Context) (T, error)) peer[T]
- type ErrorPolicy
- type GoGroup
- type GroupOption
- type Job
- type Option
- func AlwaysRestartOnFailure() Option
- func OnPost(f func()) Option
- func OnPre(f func()) Option
- func RestartOnFailure(r RestartPolicy) Option
- func WithBlockChan(c chan struct{}) Option
- func WithContext(ctx context.Context) Option
- func WithCount(c uint64) Option
- func WithTimeout(d time.Duration) Option
- func WithWaitGroup(wg *sync.WaitGroup) Option
- type RestartPolicy
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefaultContext ¶
func SetGoPanicLogger ¶
func SetGoPanicLogger(l interfaces.Logger)
SetGoPanicLogger for setting goroutine panic logger
Types ¶
type ErrorPolicy ¶
type ErrorPolicy = int8
ErrorPolicy for what to do if you encounter an error
const ( // ErrorPolicyStop will not continue with remaining goroutine ErrorPolicyStop ErrorPolicy = iota + 1 // ErrorPolicyCountine will ignore error ErrorPolicyCountine )
type GoGroup ¶
type GoGroup struct {
// contains filtered or unexported fields
}
GoGroup is a goroutine wrapper that limits the number of concurrent and generated
func NewGoGroup ¶
func NewGoGroup(opts ...GroupOption) *GoGroup
NewGoGroup is used to create a GoGroup
type GroupOption ¶
type GroupOption interface {
// contains filtered or unexported methods
}
GroupOption is option pattern for NewGoGroup
func GroupContext ¶
func GroupContext(ctx context.Context) GroupOption
GroupContext is used to set external context
func GroupErrorPolicy ¶
func GroupErrorPolicy(policy ErrorPolicy) GroupOption
GroupErrorPolicy set what to do if you encounter an error
func MaxConcurrency ¶
func MaxConcurrency(c uint64) GroupOption
MaxConcurrency is used to set max concurrency count
func MaxGoroutine ¶
func MaxGoroutine(c uint64) GroupOption
MaxGoroutine is used to set max goroutine count
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job is a goroutine controller
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option pattern
func AlwaysRestartOnFailure ¶
func AlwaysRestartOnFailure() Option
AlwaysRestartOnFailure is used to restart the job after crash
func RestartOnFailure ¶
func RestartOnFailure(r RestartPolicy) Option
RestartOnFailure to set the policy to restart the goroutine after crash
func WithBlockChan ¶
func WithBlockChan(c chan struct{}) Option
WithBlockChan for concurrent count control
func WithWaitGroup ¶
WithWaitGroup for set external waitgroup
type RestartPolicy ¶
type RestartPolicy struct { // If Times is 0, it will not restart Times int // Default restart delay time, if the call to DelayFunc fails this value is still used Delay time.Duration // If DelayFunc is set, DelayFunc is used first, otherwise Delay is used. // If the second return value is false, it will not restart DelayFunc func(int) (time.Duration, bool) // contains filtered or unexported fields }
RestartPolicy number and interval of restarts