本文整理汇总了Golang中github.com/joernweissenborn/eventual2go.NewStreamController函数的典型用法代码示例。如果您正苦于以下问题:Golang NewStreamController函数的具体用法?Golang NewStreamController怎么用?Golang NewStreamController使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewStreamController函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: NewIntStreamController
func NewIntStreamController() *IntStreamController {
return &IntStreamController{eventual2go.NewStreamController()}
}
开发者ID:joernweissenborn,项目名称:eventual2go,代码行数:3,代码来源:int_events.go
示例17: NewUUIDStreamController
func NewUUIDStreamController() *UUIDStreamController {
return &UUIDStreamController{eventual2go.NewStreamController()}
}
开发者ID:ThingiverseIO,项目名称:thingiverseio,代码行数:3,代码来源:uuid_events.go
示例18: NewMessageStreamController
func NewMessageStreamController() *MessageStreamController {
return &MessageStreamController{eventual2go.NewStreamController()}
}
开发者ID:ThingiverseIO,项目名称:thingiverseio,代码行数:3,代码来源:message_events.go
示例19: NewStringSliceStreamController
func NewStringSliceStreamController() *StringSliceStreamController {
return &StringSliceStreamController{eventual2go.NewStreamController()}
}
开发者ID:joernweissenborn,项目名称:eventual2go,代码行数:3,代码来源:stringslice_events.go
示例20: TestCallOne2Many
func TestCallOne2Many(t *testing.T) {
i := aursir4go.NewImport(TEST_APP_DESCRIPTOR, config.DefaultLocalhost())
defer i.Remove()
i.Run()
e1 := aursir4go.NewExport(TEST_APP_DESCRIPTOR, config.DefaultLocalhost())
defer e1.Remove()
c1 := e1.Requests().AsChan()
e1.Run()
e2 := aursir4go.NewExport(TEST_APP_DESCRIPTOR, config.DefaultLocalhost())
defer e2.Remove()
c2 := e2.Requests().AsChan()
e2.Run()
i.Connected().WaitUntilComplete()
e1.Connected().WaitUntilComplete()
e2.Connected().WaitUntilComplete()
params := []byte{4, 5, 63, 4}
params1 := []byte{3}
params2 := []byte{6}
s := eventual2go.NewStreamController()
s1, s2 := s.Split(func(d eventual2go.Data) bool { return d.(*messages.Result).Exporter == e1.UUID() })
rc1 := s1.AsChan()
rc2 := s2.AsChan()
i.CallAll("SayHello", params, s)
select {
case <-time.After(5 * time.Second):
t.Fatal("Didnt Got Request 1")
case d := <-c1:
r := d.(*messages.Request)
if r.Importer != i.UUID() {
t.Error("Wrong Import UUID 1", r.Importer, i.UUID())
}
var res []byte
r.Decode(&res)
if !bytes.Equal(res, params) {
t.Error("Wrong Params 1", r.Parameter(), params)
}
e1.Reply(r, params1)
}
select {
case <-time.After(2 * time.Second):
t.Fatal("Didnt Got Request 2")
case d := <-c2:
r := d.(*messages.Request)
if r.Importer != i.UUID() {
t.Error("Wrong Import UUID 2", r.Importer, i.UUID())
}
var res []byte
r.Decode(&res)
if !bytes.Equal(res, params) {
t.Error("Wrong Params 2", r.Parameter(), params)
}
e2.Reply(r, params2)
}
select {
case <-time.After(2 * time.Second):
t.Fatal("Didnt Got Result 1")
case d := <-rc1:
r := d.(*messages.Result)
if r.Exporter != e1.UUID() {
t.Error("Wrong Export UUID", r.Exporter, e1.UUID())
}
var res []byte
r.Decode(&res)
if !bytes.Equal(res, params1) {
t.Error("Wrong Params", r.Parameter(), params1)
}
}
select {
case <-time.After(2 * time.Second):
t.Fatal("Didnt Got Result 2")
case d := <-rc2:
r := d.(*messages.Result)
if r.Exporter != e2.UUID() {
t.Error("Wrong Export UUID", r.Exporter, e2.UUID())
}
var res []byte
r.Decode(&res)
if !bytes.Equal(res, params2) {
t.Error("Wrong Params", r.Parameter(), params2)
}
}
}
开发者ID:joernweissenborn,项目名称:aursir4go,代码行数:91,代码来源:aursir_test.go
注:本文中的github.com/joernweissenborn/eventual2go.NewStreamController函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论