当前位置: 首页>>代码示例>>Golang>>正文


Golang eventual2go.NewStreamController函数代码示例

本文整理汇总了Golang中github.com/joernweissenborn/eventual2go.NewStreamController函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStreamController函数的具体用法?Golang NewStreamController怎么用?Golang NewStreamController使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewStreamController函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NewClientTracker

func NewClientTracker(address string, port int) (p *ClientTracker) {
	p = new(ClientTracker)
	p.address = address
	p.port = port
	p.clients = map[string]time.Time{}
	p.new = eventual2go.NewStreamController()
	p.gone = eventual2go.NewStreamController()
	p.logger = log.New(os.Stdout, "clienttracker ", log.Lshortfile)
	return
}
开发者ID:YamiNoKeshin,项目名称:aurarath,代码行数:10,代码来源:client_tracker.go

示例2: NewOutgoing

func NewOutgoing(uuid string, targetAddress string, targetPort int) (out *eventual2go.StreamController, err error) {

	var o Outgoing

	o.Mutex = new(sync.Mutex)

	o.skt, err = zmq4.NewSocket(zmq4.DEALER)

	if err != nil {
		return
	}

	err = o.skt.SetIdentity(uuid)
	if err != nil {
		return
	}

	err = o.skt.Connect(fmt.Sprintf("tcp://%s:%d", targetAddress, targetPort))

	if err != nil {
		return
	}
	out = eventual2go.NewStreamController()
	out.Stream.Listen(o.send)
	out.Stream.Closed().Then(o.Close)
	return
}
开发者ID:AurSir,项目名称:aurarath,代码行数:27,代码来源:outgoing.go

示例3: NewAnnouncer

func NewAnnouncer(uuid string, addresses []string, servicetype string, desc *appdescriptor.AppDescriptor) (a *Announcer) {

	cfg := config.DefaultLocalhost()

	a = new(Announcer)
	a.announced = eventual2go.NewCompleter()
	a.logger = log.New(cfg.Logger(), fmt.Sprintf("announcer %s ", uuid), log.Lshortfile)

	a.new = eventual2go.NewStreamController()
	a.servicetype = servicetype
	addrs := []string{}
	a.clientPorts = map[string]int{}

	for _, addr := range addresses {
		as := strings.Split(addr, ":")
		addrs = append(addrs, as[0])
		p, _ := strconv.ParseInt(as[1], 0, 0)
		a.clientPorts[as[0]] = int(p)
		a.logger.Println("adding address", as[0], int(p))
	}

	cfg.NetworkInterfaces = addrs
	a.node = node.New(uuid, cfg, desc.AsTagSet())

	a.r = eventual2go.NewReactor()
	a.r.React("first_join", a.announce)
	a.r.AddFuture("first_join", a.node.Join().First())
	a.r.React("service_found", a.replyToServiceQuery)
	a.r.AddStream("service_found", a.node.Queries().WhereNot(isService(a.servicetype)))
	a.logger.Println("setup finished")
	return
}
开发者ID:YamiNoKeshin,项目名称:aurarath,代码行数:32,代码来源:announcer.go

示例4: newEventHandler

func newEventHandler() (eh eventHandler) {
	eh.stream = eventual2go.NewStreamController()
	eh.join = eh.stream.Where(isJoin).Transform(toMember)
	eh.leave = eh.stream.Where(isLeave).Transform(toMember)
	eh.query = eh.stream.Where(isQuery)
	return
}
开发者ID:AurSir,项目名称:aurarath,代码行数:7,代码来源:eventhandler.go

示例5: announce

func (a *Announcer) announce(eventual2go.Data) {
	a.logger.Println("announcing")
	results := eventual2go.NewStreamController()
	c := results.AsChan()
	a.node.Query(a.servicetype, nil, results)
	go a.collectAnnounceResponses(c)
	return
}
开发者ID:YamiNoKeshin,项目名称:aurarath,代码行数:8,代码来源:announcer.go

示例6: init

func (b *Beacon) init() {
	b.in = eventual2go.NewStreamController()
	b.stop = make(chan struct{})
	b.outConns = []*net.UDPConn{}
	b.silence = eventual2go.NewCompleter()
	b.silent = true
	b.logger = log.New(b.conf.Logger, fmt.Sprintf("beacon %v ", b.payload[1]), log.Lshortfile)
}
开发者ID:joernweissenborn,项目名称:aurarath,代码行数:8,代码来源:beacon.go

示例7: NewIncoming

func NewIncoming(addr string) (i *Incoming, err error) {
	i = new(Incoming)
	i.m = new(sync.Mutex)
	i.addr = addr
	i.in = eventual2go.NewStreamController()
	err = i.setupSocket()
	if err == nil {
		go i.listen()
	}
	return
}
开发者ID:AurSir,项目名称:aurarath,代码行数:11,代码来源:incoming.go

示例8: replyToExport

func (a *Announcer) replyToExport(d eventual2go.Data) {
	q := d.(node.QueryEvent)
	a.logger.Println("found exporting service: ", q.Query.Payload)
	a.logger.Println(q)

	results := eventual2go.NewStreamController()
	c := results.AsChan()
	go a.collectAnnounceResponses(c)

	a.node.QueryUuid(fmt.Sprintf("%s", q.Query.Payload), IMPORTING, nil, results)
}
开发者ID:joernweissenborn,项目名称:aurarath,代码行数:11,代码来源:announcer.go

示例9: announce

func (a *Announcer) announce(eventual2go.Data) {
	a.logger.Println("announcing")
	var results *eventual2go.StreamController
	if a.servicetype == IMPORTING {
		results = eventual2go.NewStreamController()
		c := results.AsChan()
		go a.collectAnnounceResponses(c)
	} else {
		a.announced.Complete(nil)
	}
	a.node.Query(a.servicetype, a.node.UUID, results)
	return
}
开发者ID:joernweissenborn,项目名称:aurarath,代码行数:13,代码来源:announcer.go

示例10: NewService

func NewService(dsc *servicedescriptor.ServiceDescriptor, servicetype string, cfg *config.Config, codecs []byte) (s *Service) {
	s = new(Service)

	if cfg.UUID == "" {
		id, _ := uid.NewV4()
		cfg.UUID = id.String()
	}
	s.uuid = cfg.UUID
	s.logger = log.New(cfg.Logger(), fmt.Sprintf("service %s  ", s.uuid), log.Lshortfile)
	s.serviceDescriptor = dsc

	s.logger.Println("ServiceDesctiptor TagsSet is", dsc.AsTagSet())

	s.servicetype = servicetype
	s.codecs = codecs
	s.newpeers = eventual2go.NewStreamController()
	s.gonepeers = eventual2go.NewStreamController()

	s.incoming = map[string]*connection.Incoming{}
	s.in = eventual2go.NewStreamController()

	s.connectedServices = map[string]*ServiceConnection{}
	s.connected = eventual2go.NewCompleter()
	s.disconnected = eventual2go.NewCompleter()
	s.remove = eventual2go.NewCompleter()

	s.r = eventual2go.NewReactor()
	s.r.React("service_arrived", s.serviceArrived)
	s.r.React("service_gone", s.serviceGone)
	s.r.React("announce_finish", s.announced)
	s.r.React("service_shake_hand", s.serviceHandshake)
	s.r.AddStream("service_shake_hand", s.in.Where(messages.Is(messages.HELLO)))
	s.r.React("service_shake_hand_reply", s.serviceHandShakeReply)
	s.r.AddStream("service_shake_hand_reply", s.in.Where(messages.Is(messages.HELLO_OK)))
	s.createIncoming(cfg)
	s.createAnnouncer(cfg)
	return
}
开发者ID:joernweissenborn,项目名称:aurarath,代码行数:38,代码来源:service.go

示例11: New

func New(uuid string, cfg *config.Config, tags map[string]string) (node *Node) {

	node = new(Node)
	node.logger = log.New(cfg.Logger(), fmt.Sprintf("node %s ", uuid), log.Lshortfile)

	node.logger.Println("Initializing")

	node.cfg = cfg
	node.tags = tags

	node.UUID = uuid
	node.beacons = []*beacon.Beacon{}
	node.logger.Println("Launching Serf Agents")

	node.join = eventual2go.NewStreamController()
	node.join.First().Then(node.silenceBeacons)
	node.leave = eventual2go.NewStreamController()
	node.query = eventual2go.NewStreamController()

	node.createSerfAgents()

	return node
}
开发者ID:joernweissenborn,项目名称:aurarath,代码行数:23,代码来源:node.go

示例12: NewAnnouncer

func NewAnnouncer(uuid string, servicetype string, desc *servicedescriptor.ServiceDescriptor, cfg *config.Config, ports []int) (a *Announcer) {

	a = &Announcer{
		announced:   eventual2go.NewCompleter(),
		clientPorts: map[string]int{},
		logger:      log.New(cfg.Logger(), fmt.Sprintf("announcer %s ", uuid), log.Lshortfile),
		new:         eventual2go.NewStreamController(),
		node:        node.New(uuid, cfg, desc.AsTagSet()),
		servicetype: servicetype,
	}

	a.setPorts(cfg, ports)

	a.initReactor()

	return
}
开发者ID:joernweissenborn,项目名称:aurarath,代码行数:17,代码来源:announcer.go

示例13: listenUdp

func (p *ClientTracker) listenUdp() *eventual2go.Stream {
	addr := &net.UDPAddr{IP: net.ParseIP(p.address), Port: p.port}
	p.logger.Println("Starting to listen on", addr)
	conn, err := net.ListenUDP("udp4", addr)
	if err != nil {
		fmt.Println(err)
		panic(err)
	}
	s := eventual2go.NewStreamController()
	go func(stream *eventual2go.StreamController) {
		for {
			data := make([]byte, 128)
			read, _, _ := conn.ReadFromUDP(data)
			stream.Add(data[:read])
		}
	}(s)

	return s.Stream
}
开发者ID:YamiNoKeshin,项目名称:aurarath,代码行数:19,代码来源:client_tracker.go

示例14: NewResultStreamController

func NewResultStreamController() *ResultStreamController {
	return &ResultStreamController{eventual2go.NewStreamController()}
}
开发者ID:ThingiverseIO,项目名称:thingiverseio,代码行数:3,代码来源:result_events.go

示例15: NewNodeStreamController

func NewNodeStreamController() *NodeStreamController {
	return &NodeStreamController{eventual2go.NewStreamController()}
}
开发者ID:ThingiverseIO,项目名称:thingiverseio,代码行数:3,代码来源:node_events.go


注:本文中的github.com/joernweissenborn/eventual2go.NewStreamController函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。