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 } }
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 } }
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: } } }