Documentation
¶
Overview ¶
Package worker 提供可组合到 beauty.App 的后台工作者 Service 实现。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLeaderTicker ¶
func NewLeaderTicker(name string, elector dlock.Elector, interval time.Duration, fn func(ctx context.Context), opts ...TickerOption) *leaderTickerService
NewLeaderTicker 创建带选主的定时 Service。只有 leader 实例运行 fn。
elector, _ := dlock.NewElectorAuto()
beauty.New(
worker.NewLeaderTicker("sync", elector, 10*time.Second, syncFn),
)
Types ¶
Click to show internal directories.
Click to hide internal directories.