Beispiel #1
0
func MakeClerk(shardmasters []string) *Clerk {
	ck := new(Clerk)
	ck.sm = shardmaster.MakeClerk(shardmasters)
	ck.id = strconv.Itoa(int(nrand()))
	ck.counter = 0

	ck.addr = "/var/tmp/824-" + ck.id
	ck.Receive = make(chan messagebroker.PublishArgs)
	ck.mb = messagebroker.MakeClerk(ck.addr, ck.Receive)
	return ck
}
Beispiel #2
0
func MakeDemo() *Demo {
	demo := new(Demo)
	publications := make(chan messagebroker.PublishArgs)
	addr := port("demo-clerk", 0)
	ck := messagebroker.MakeClerk(addr, publications)

	demo.pubchan = publications
	demo.clerk = ck
	demo.addr = addr

	go func() {
		for {
			pub := <-demo.pubchan
			fmt.Printf("Received notification- posting\n")
			if pub.Type == messagebroker.Put {
				postData(pub.PutArgs)
			}
		}
	}()

	return demo
}