예제 #1
0
파일: srv.go 프로젝트: keryoo/circuit
func New(kin *tissue.Kin) Server {
	return &server{
		addr:   kin.Avatar().X.Addr().String(),
		kin:    kin,
		joined: time.Now(),
	}
}
예제 #2
0
파일: tube.go 프로젝트: herokai/circuit
// NewTube…
func NewTube(kin *tissue.Kin, topic string) *Tube {
	t := &Tube{view: NewView()}
	t.av = tissue.FolkAvatar{
		X:  circuit.PermRef(XTube{t}),
		ID: lang.ComputeReceiverID(t),
	}
	t.folk = kin.Attach(topic, t.av)
	go func() {
		for {
			// Consume identities of new downstream nodes
			t.superscribe(t.folk.Replenish())
		}
	}()
	return t
}
예제 #3
0
파일: locus.go 프로젝트: keryoo/circuit
// NewLocus creates a new locus device.
func NewLocus(kin *tissue.Kin, rip <-chan tissue.KinAvatar) XLocus {
	locus := &Locus{
		tube: tube.NewTube(kin, "locus"),
	}
	term, xterm := anchor.NewTerm(kin.Avatar().ID.String(), locus)
	term.Attach(anchor.Server, srv.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.Avatar(),
		Term: xterm,
	}
	go locus.loopRIP(rip)
	go locus.loopAnnounceAndExpire()
	return XLocus{locus}
}