本文整理匯總了Golang中doozer/store.Store.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang Store.Get方法的具體用法?Golang Store.Get怎麽用?Golang Store.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類doozer/store.Store
的用法示例。
在下文中一共展示了Store.Get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: activate
func activate(st *store.Store, self string, c *doozer.Client) int64 {
w := store.NewWatch(st, calGlob)
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
}
w.Stop()
return seqn
}
}
for ev := range w.C {
// 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
}
w.Stop()
return seqn
}
}
return 0
}
示例2: Clean
func Clean(s *store.Store, p paxos.Proposer) {
timer := timer.New("/session/**", timer.OneSecond, s)
for tick := range timer.C {
_, cas := s.Get(tick.Path)
paxos.Del(p, tick.Path, cas)
}
}
示例3: readdirMap
func readdirMap(st *store.Store, path string) map[string]string {
m := map[string]string{}
keys, cas := st.Get(path)
if cas != store.Dir {
return map[string]string{}
}
for _, key := range keys {
v, cas := st.Get(path + "/" + key)
if cas != store.Dir && cas != store.Missing {
m[key] = v[0]
}
}
return m
}
示例4: walk
func walk(path string, st *store.Store, ch chan store.Event) {
for path != "/" && strings.HasSuffix(path, "/") {
// TODO generalize and factor this into pkg store.
path = path[0 : len(path)-1]
}
v, rev := st.Get(path)
if rev != store.Dir {
ch <- store.Event{0, path, v[0], rev, "", nil, nil}
return
}
if path == "/" {
path = ""
}
for _, ent := range v {
walk(path+"/"+ent, st, ch)
}
}
示例5: 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
}