Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MultiParamWork ¶
type MultiParamWork struct { Data []interface{} Func func(...interface{}) (interface{}, error) }
MultiParamWork is a utility for doing a multi param work
func (*MultiParamWork) Work ¶
func (mpw *MultiParamWork) Work() (interface{}, error)
Work satisfies Work interface. So we can now pass an anonymous function casted to MultiParamWork
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner holds data for initiating parallel work
func NewBoundedRunner ¶
NewBoundedRunner creates bounded goroutines by factor parallel count
func NewFixedBoundedRunner ¶
NewFixedBoundedRunner creates fixed bounded goroutines by factor of available CPU based on default setting. Default setting is to have parallelization as factor of 4x if iobound work which is supposed to be short. If its a long work use NewBoundedRunner instead with optimal config. If cpu bound work parallel go routine will be bound by cpu.
func NewUnboundedRunner ¶
NewUnboundedRunner creates unbounded goroutines
func (*Runner) GetResult ¶
GetResult returns array of responses from executing Work and returns early on first error it gets. Also after calling this no more work can be submitted to the Runner
func (*Runner) SubmitWork ¶
SubmitWork submits a unit of work to be executed
type SingleParamWork ¶
type SingleParamWork struct { Data interface{} Func func(data interface{}) (interface{}, error) }
SingleParamWork is a utility for doing a single param work
func (*SingleParamWork) Work ¶
func (spw *SingleParamWork) Work() (interface{}, error)
Work satisfies Work interface. So we can now pass an anonymous function casted to SingleParamWork
type StatelessFunc ¶
type StatelessFunc func() (interface{}, error)
StatelessFunc is defined to simulate anonymous implementation directly lacking in golang. It will avoid creating boilerplate implementation of Work interface
func (StatelessFunc) Work ¶
func (sf StatelessFunc) Work() (interface{}, error)
Work satisfies Work interface. So we can now pass an anonymous function casted to StatelessFunc
type ThreeParamWork ¶
type ThreeParamWork struct { Data1 interface{} Data2 interface{} Data3 interface{} Func func(data1 interface{}, data2 interface{}, data3 interface{}) (interface{}, error) }
ThreeParamWork is a utility for doing a three param work
func (*ThreeParamWork) Work ¶
func (tpw *ThreeParamWork) Work() (interface{}, error)
Work satisfies Work interface. So we can now pass an anonymous function casted to ThreeParamWork
type TwoParamWork ¶
type TwoParamWork struct { Data1 interface{} Data2 interface{} Func func(data1 interface{}, data2 interface{}) (interface{}, error) }
TwoParamWork is a utility for doing a two param work
func (*TwoParamWork) Work ¶
func (tpw *TwoParamWork) Work() (interface{}, error)
Work satisfies Work interface. So we can now pass an anonymous function casted to TwoParamWork