Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CallBackFunc ¶
type CallBackFunc func(obj interface{}) int
CallBackFunc will be called after processing an object
type DefaultLoadBalancer ¶
type DefaultLoadBalancer struct {
// contains filtered or unexported fields
}
func (*DefaultLoadBalancer) Handle ¶
func (lb *DefaultLoadBalancer) Handle(obj interface{}) int
func (*DefaultLoadBalancer) Run ¶
func (lb *DefaultLoadBalancer) Run(ctx context.Context)
func (*DefaultLoadBalancer) SetCallBack ¶
func (lb *DefaultLoadBalancer) SetCallBack(cb CallBackFunc)
func (*DefaultLoadBalancer) Workers ¶
func (lb *DefaultLoadBalancer) Workers() []*Worker
type LoadBalancer ¶
type LoadBalancer interface { // Start load balancer Run(ctx context.Context) // Do the load balancing and distribute packets to workers Handle(obj interface{}) int // Return workers Workers() []*Worker // Set callback function for worker to do post processing SetCallBack(cb CallBackFunc) }
func NewDefaultLoadBalancer ¶
func NewDefaultLoadBalancer(numWorkers int) (LoadBalancer, error)
type Worker ¶
func (*Worker) Distribute ¶
func (*Worker) SetCallBack ¶
func (w *Worker) SetCallBack(cb CallBackFunc)
Click to show internal directories.
Click to hide internal directories.