Exemple #1
0
func bgSet(p consensus.Proposer, k string, v []byte, c int64) chan store.Event {
	ch := make(chan store.Event)
	go func() {
		ch <- consensus.Set(p, k, v, c)
	}()
	return ch
}
Exemple #2
0
func (t *txn) set() {
	if t.c.access == false {
		t.respondOsError(os.EACCES)
		return
	}

	if !t.c.canWrite {
		t.respondErrCode(response_READONLY)
		return
	}

	if t.req.Path == nil || t.req.Rev == nil {
		t.respondErrCode(response_MISSING_ARG)
		return
	}

	go func() {
		ev := consensus.Set(t.c.p, *t.req.Path, t.req.Value, *t.req.Rev)
		if ev.Err != nil {
			t.respondOsError(ev.Err)
			return
		}
		t.resp.Rev = &ev.Seqn
		t.respond()
	}()
}
Exemple #3
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
	})
}
Exemple #4
0
func Pulse(node string, seqns <-chan int64, p consensus.Proposer, sleep int64) {
	path := "/ctl/node/" + node + "/applied"
	for {
		seqn, ok := <-seqns
		if !ok {
			break
		}

		e := consensus.Set(p, path, []byte(strconv.Itoa64(seqn)), store.Clobber)
		if e.Err != nil {
			log.Println(e.Err)
		}

		time.Sleep(sleep)
	}
}