當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Conn.Wait方法代碼示例

本文整理匯總了Golang中github.com/ha/doozer.Conn.Wait方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Wait方法的具體用法?Golang Conn.Wait怎麽用?Golang Conn.Wait使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ha/doozer.Conn的用法示例。


在下文中一共展示了Conn.Wait方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: watch

func watch(conn *doozer.Conn, events chan doozer.Event, revs chan int64) {
	for {
		rev := <-revs
		event, err := conn.Wait("/*", rev)
		if err != nil {
			panic("error waiting for event, bailing")
		}
		revs <- event.Rev + 1
		events <- event
	}
}
開發者ID:sclasen,項目名稱:scoop,代碼行數:11,代碼來源:scoop.go

示例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
	}
}
開發者ID:CrazyJvm,項目名稱:doozerd,代碼行數:13,代碼來源:misc_test.go

示例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:
		}
	}
}
開發者ID:bmizerany,項目名稱:doozerd,代碼行數:20,代碼來源:peer.go

示例4: wait

// wait waits on a changes for the fiven file starting at the given
// revision from the given doozer connection. It sends updated peer
// lists on the returned channel.
func wait(d *doozer.Conn, file string, rev *int64) chan []string {
	c := make(chan []string, 1)
	cur := *rev
	go func() {
		for {
			// Wait for the change.
			e, err := d.Wait(file, cur+1)
			if err != nil {
				log.Println("waiting failed (no longer watching):", err)
				close(c)
				return
			}
			// Update the revision and send the change on the channel.
			atomic.CompareAndSwapInt64(rev, cur, e.Rev)
			cur = e.Rev
			c <- strings.Split(string(e.Body), " ")
		}
	}()

	return c
}
開發者ID:pombredanne,項目名稱:CodeSnippet,代碼行數:24,代碼來源:main.go


注:本文中的github.com/ha/doozer.Conn.Wait方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。