本文整理汇总了Golang中github.com/soundcloud/doozer.Conn.Wait方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.Wait方法的具体用法?Golang Conn.Wait怎么用?Golang Conn.Wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/soundcloud/doozer.Conn
的用法示例。
在下文中一共展示了Conn.Wait方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: wait
func wait(
conn *doozer.Conn,
rev int64,
root string,
entryc chan *journal.Entry,
errc chan error,
) {
for {
ev, err := conn.Wait(path.Join(root, "**"), rev+1)
if err != nil {
errc <- fmt.Errorf("error waiting for event: %s", err)
return
}
rev = ev.Rev
var entry *journal.Entry
if ev.IsSet() {
entry = journal.NewEntry(ev.Rev, journal.OpSet, ev.Path, ev.Body)
} else if ev.IsDel() {
entry = journal.NewEntry(ev.Rev, journal.OpDel, ev.Path, []byte{})
} else {
continue
}
entryc <- entry
}
}
示例2: waitFor
func waitFor(cl *doozer.Conn, path string) {
var rev int64
for {
ev, err := cl.Wait(path, rev)
if err != nil {
panic(err)
}
if ev.IsSet() && len(ev.Body) > 0 {
break
}
rev = ev.Rev + 1
}
}
示例3: follow
func follow(st *store.Store, cl *doozer.Conn, rev int64, stop chan bool) {
for {
ev, err := cl.Wait("/**", rev)
if err != nil {
panic(err)
}
// store.Clobber is okay here because the event
// has already passed through another store
mut := store.MustEncodeSet(ev.Path, string(ev.Body), store.Clobber)
st.Ops <- store.Op{ev.Rev, mut}
rev = ev.Rev + 1
select {
case <-stop:
return
default:
}
}
}