Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Campaign ¶
func Campaign(c *clientv3.Client, parentCtx context.Context, wg *sync.WaitGroup, CampaignPrefix string) (success <-chan struct{})
这里返回的 channel 表示已经成功选主为 leader 所有worker可以监听这个channel,这种实现可以让worker阻塞等待节点成为leader,而不是轮询是否是leader节点。
func InitDaemon ¶
func InitDaemon(wg *sync.WaitGroup) (cancel context.CancelFunc)
Types ¶
type Option ¶
type Option func(info *WorkerInfo)
func WithBusySleepTime ¶
func WithIdleSleepTime ¶
type WorkerInfo ¶
type WorkerInfo struct { Name string IdleSleepTime time.Duration BusySleepTime time.Duration MaxPanicRecoverCount int Task TaskFunc // contains filtered or unexported fields }
func NewWorker ¶
func NewWorker(task TaskFunc, opts ...Option) (w *WorkerInfo)
func (*WorkerInfo) Work ¶
func (w *WorkerInfo) Work()
Click to show internal directories.
Click to hide internal directories.