예제 #1
0
파일: tube.go 프로젝트: prodigeni/circuit
func New(kin *kinfolk.Kin, topic string) *Tube {
	t := &Tube{
		lookup:     make(map[string]int),
		downstream: kinfolk.NewRotor(),
	}
	t.permXID = kinfolk.FolkXID{
		X:  circuit.PermRef(XTube{t}),
		ID: lang.ComputeReceiverID(t),
	}
	t.folk = kin.Attach(topic, t.permXID)
	go t.loop()
	return t
}
예제 #2
0
파일: locus.go 프로젝트: prodigeni/circuit
// NewLocus creates a new locus device.
func NewLocus(kin *kinfolk.Kin, kinJoin, kinLeave <-chan kinfolk.KinXID) XLocus {
	locus := &Locus{
		tube: tube.New(kin, "locus"),
		Peer: &Peer{
			// It is crucial to use permanent cross-references, and not
			// "plain" ones within values stored inside the tube table. If
			// cross-references are used, they are managed by the cross-
			// garbage collection system and therefore connections to ALL
			// underlying workers are maintained superfluously.
			Kin:  kin.XID(),
			Term: anchor.NewTerm(kin.XID().ID.String()),
		},
	}
	go loopJoin(kinJoin)
	go locus.loopLeave(kinLeave)
	go locus.loopExpire()
	//log.Println(locus.Peer.Key())
	return XLocus{locus}
}