Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
// Use your custom sync.WaitGroup
WithWg(wg *sync.WaitGroup) Interface
// Use your custom sync.Locker
WithLocker(lc sync.Locker) Interface
// Set maximum worker here. Default is 1
WithMaxWorker(maxWorker int64) Interface
// Run the list functions with goroutine. The list method will be cleared after calling this method.
Do(ctx context.Context) error
// Added function that will be run async at goroutine. This method already call c.Done() after process is complete
AddFunc(fn func(ctx context.Context, c Interface))
// Lock block of code. This like (sync.Mutex{}).Lock()
Lock()
// Unlock block of code. This like (sync.Mutex{}).Unlock()
Unlock()
// To flag wait group if proccess is done. This like wg.Done()
Done()
// Added errors if have error. This method already implement c.Lock() and c.Unlock(). The error will be returned at Do() method if exists. Recommended to use errors.NewWithCode()
AddError(errs ...error)
// To clear list functions
ClearFunc()
// Get value of maximum worker
GetMaxWorker() int64
// Create clone object of this concurrency with empty list function or etc but with same max worker
Clone() Interface
// Get list errors
GetErrors() []error
}
func NewConcurrency ¶
func NewConcurrency() Interface
Do concurrency proccess with custom maximum worker
Click to show internal directories.
Click to hide internal directories.