本文整理匯總了Golang中doozer/store.Store.Wait方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.Wait方法的具體用法?Golang Store.Wait怎麽用?Golang Store.Wait使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類doozer/store.Store
的用法示例。
在下文中一共展示了Store.Wait方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: mustWait
func mustWait(s *store.Store, n int64) <-chan store.Event {
c, err := s.Wait(store.Any, n)
if err != nil {
panic(err)
}
return c
}
示例2: sendLearn
func sendLearn(out chan<- Packet, p *packet, st *store.Store) {
if p.msg.Cmd != nil && *p.msg.Cmd == msg_INVITE {
ch, err := st.Wait(store.Any, *p.Seqn)
if err == store.ErrTooLate {
log.Println(err)
} else {
e := <-ch
m := msg{
Seqn: &e.Seqn,
Cmd: learn,
Value: []byte(e.Mut),
}
buf, _ := proto.Marshal(&m)
out <- Packet{p.Addr, buf}
}
}
}
示例3: activate
func activate(st *store.Store, self string, c *doozer.Conn) int64 {
rev, _ := st.Snap()
for _, base := range store.Getdir(st, calDir) {
p := calDir + "/" + base
v, rev := st.Get(p)
if rev != store.Dir && v[0] == "" {
seqn, err := c.Set(p, rev, []byte(self))
if err != nil {
log.Println(err)
continue
}
return seqn
}
}
for {
ch, err := st.Wait(calGlob, rev+1)
if err != nil {
panic(err)
}
ev, ok := <-ch
if !ok {
panic(os.EOF)
}
rev = ev.Rev
// TODO ev.IsEmpty()
if ev.IsSet() && ev.Body == "" {
seqn, err := c.Set(ev.Path, ev.Rev, []byte(self))
if err != nil {
log.Println(err)
continue
}
return seqn
} else if ev.IsSet() && ev.Body == self {
return ev.Seqn
}
}
return 0
}
示例4: generateRuns
func generateRuns(rev, alpha int64, st *store.Store, runs chan<- *run, t run) {
for {
ch, err := st.Wait(store.Any, rev)
if err != nil {
panic(err) // can't happen
}
e := <-ch
if closed(ch) {
break
}
rev = e.Seqn + 1
r := t
r.seqn = e.Seqn + alpha
r.cals = getCals(e)
r.addrs = getAddrs(e)
r.c.size = len(r.cals)
r.c.quor = r.quorum()
r.c.crnd = r.indexOf(r.self) + int64(len(r.cals))
r.l.init(int64(r.quorum()))
runs <- &r
}
}