本文整理汇总了Golang中github.com/juju/juju/worker/leadership.Tracker类的典型用法代码示例。如果您正苦于以下问题:Golang Tracker类的具体用法?Golang Tracker怎么用?Golang Tracker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tracker类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewLeadershipContext
func NewLeadershipContext(accessor LeadershipSettingsAccessor, tracker leadership.Tracker) LeadershipContext {
return &leadershipContext{
accessor: accessor,
tracker: tracker,
serviceName: tracker.ServiceName(),
}
}
示例2: assertClaimLeader
func assertClaimLeader(c *gc.C, tracker leadership.Tracker, expect bool) {
// Grab a ticket...
ticket := tracker.ClaimLeader()
// ...and check that it gives the expected result every time it's checked.
assertTicket(c, ticket, expect)
assertTicket(c, ticket, expect)
}
示例3: assertWaitMinion
func assertWaitMinion(c *gc.C, tracker leadership.Tracker, expect bool) {
ticket := tracker.WaitMinion()
if expect {
assertTicket(c, ticket, false)
assertTicket(c, ticket, false)
return
}
select {
case <-time.After(trackerDuration / 4):
// This wait needs to be small, compared to the resolution we run the
// tests at, so as not to disturb client timing too much.
case <-ticket.Ready():
c.Fatalf("got unexpected readiness: %v", ticket.Wait())
}
}