本文整理汇总了Golang中github.com/4ad/doozerd/store.Store类的典型用法代码示例。如果您正苦于以下问题:Golang Store类的具体用法?Golang Store怎么用?Golang Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Clean
func Clean(c chan string, st *store.Store, p consensus.Proposer) {
for addr := range c {
_, g := st.Snap()
name := getName(addr, g)
if name != "" {
go func() {
clearSlot(p, g, name)
removeInfo(p, g, name)
}()
}
}
}
示例3: 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)
}
}
示例4: 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}
}
}
}
示例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(io.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
}
示例6: Clean
func Clean(st *store.Store, keep int64, ticker <-chan time.Time) {
for _ = range ticker {
last := (<-st.Seqns) - keep
st.Clean(last)
}
}