Exemplo n.º 1
0
// NewTube…
func NewTube(kin *kinfolk.Kin, topic string) *Tube {
	t := &Tube{view: NewView()}
	t.xid = kinfolk.FolkXID{
		X:  circuit.PermRef(XTube{t}),
		ID: lang.ComputeReceiverID(t),
	}
	t.folk = kin.Attach(topic, t.xid)
	go func() {
		for {
			// Consume identities of new downstream nodes
			t.superscribe(t.folk.Replenish())
		}
	}()
	return t
}
Exemplo n.º 2
0
// NewLocus creates a new locus device.
func NewLocus(kin *kinfolk.Kin, rip <-chan kinfolk.KinXID) XLocus {
	locus := &Locus{
		tube: tube.NewTube(kin, "locus"),
	}
	term, xterm := anchor.NewTerm(kin.XID().ID.String(), locus)
	term.Attach(anchor.Server, srv.New(kin.XID().X.Addr().String()))
	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: xterm,
	}
	go locus.loopRIP(rip)
	go locus.loopAnnounceAndExpire()
	return XLocus{locus}
}