Beispiel #1
0
func clearSlot(p consensus.Proposer, g store.Getter, name string) {
	store.Walk(g, calGlob, func(path, body string, rev int64) bool {
		if body == name {
			consensus.Set(p, path, nil, rev)
		}
		return false
	})
}
Beispiel #2
0
func (t *txn) walk() {
	trace := t.instrumentVerb()

	if !t.c.raccess {
		t.respondOsError(syscall.EACCES)
		trace("eacces")
		return
	}

	if t.req.Path == nil || t.req.Offset == nil {
		t.respondErrCode(Response_MISSING_ARG)
		trace("emissingarg")
		return
	}

	glob, err := store.CompileGlob(*t.req.Path)
	if err != nil {
		t.respondOsError(err)
		trace("eunknown")
		return
	}

	offset := *t.req.Offset
	if offset < 0 {
		t.respondErrCode(Response_RANGE)
		trace("erange")
		return
	}

	go func() {
		g, err := t.getter()
		if err != nil {
			t.respondOsError(err)
			trace("eunknown")
			return
		}

		f := func(path, body string, rev int64) (stop bool) {
			if offset == 0 {
				t.resp.Path = &path
				t.resp.Value = []byte(body)
				t.resp.Rev = &rev
				t.resp.Flags = proto.Int32(set)
				t.respond()
				trace("success")
				return true
			}
			offset--
			return false
		}
		if !store.Walk(g, glob, f) {
			t.respondErrCode(Response_RANGE)
			trace("erange")
		}
	}()
}
Beispiel #3
0
func removeInfo(p consensus.Proposer, g store.Getter, name string) {
	glob, err := store.CompileGlob("/ctl/node/" + name + "/**")
	if err != nil {
		log.Println(err)
		return
	}
	store.Walk(g, glob, func(path, _ string, rev int64) bool {
		consensus.Del(p, path, rev)
		return false
	})
}