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


Golang Hive.Emit方法代码示例

本文整理汇总了Golang中github.com/kandoo/beehive.Hive.Emit方法的典型用法代码示例。如果您正苦于以下问题:Golang Hive.Emit方法的具体用法?Golang Hive.Emit怎么用?Golang Hive.Emit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/kandoo/beehive.Hive的用法示例。


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

示例1: RegisterDiscovery

// RegisterDiscovery registers the discovery module for topology discovery on the hive.
// you can use it's REST API in order to communicate with it.
func RegisterDiscovery(h bh.Hive) {
	a := h.NewApp("discovery")
	a.Handle(nom.NodeJoined{}, &nodeJoinedHandler{})
	a.Handle(nom.NodeLeft{}, &nodeLeftHandler{})

	a.Handle(nom.PortUpdated{}, &portUpdateHandler{})
	// TODO(soheil): Handle PortRemoved.

	a.Handle(nom.PacketIn{}, &lldpPktInHandler{})

	a.Handle(nom.PacketIn{}, &arpPktInHandler{})

	a.Handle(nom.HostConnected{}, &hostConnectedHandler{})

	a.Handle(NewLink{}, &newLinkHandler{})
	a.Handle(lldpTimeout{}, &timeoutHandler{})
	go func() {
		for {
			h.Emit(lldpTimeout{})
			time.Sleep(60 * time.Second)
		}
	}()

	http.NewHTTPApp(a, h).DefaultHandle()

	a.Handle(http.HTTPRequest{}, &httpHostListHandler{})
}
开发者ID:1995parham,项目名称:FlyNest,代码行数:29,代码来源:bh.go

示例2: RegisterTaskQ

// RegisterTaskQ registers the TaskQ application and all its handler in the
// hive.
func RegisterTaskQ(h beehive.Hive, opts ...Option) error {
	if !flag.Parsed() {
		flag.Parse()
	}

	proto, err := NewProtoHandler(addr.Get(opts))
	if err != nil {
		return err
	}

	r := rate.Get(opts)
	taskq := h.NewApp("taskq", beehive.Persistent(repl.Get(opts)),
		beehive.OutRate(bucket.Rate(r), 2*r))
	taskq.Handle(Enque{}, EnQHandler{})
	taskq.Handle(Deque{}, DeQHandler{})
	taskq.Handle(Ack{}, AckHandler{})
	taskq.Handle(Timeout{}, TimeoutHandler{
		ExpDur: 60 * time.Second,
	})

	ah := &AckHTTPHandler{Hive: h}
	taskq.HandleHTTP("/{queue}/tasks/{id:[0-9]+}", ah).Methods("DELETE")
	dh := &DeQHTTPHandler{Hive: h}
	taskq.HandleHTTP("/{queue}/tasks/deque", dh).Methods("POST")
	eh := &EnQHTTPHandler{Hive: h}
	taskq.HandleHTTP("/{queue}/tasks", eh).Methods("POST")

	taskq.Detached(beehive.NewTimer(30*time.Second, func() {
		h.Emit(Timeout(time.Now()))
	}))
	taskq.Detached(proto)

	return nil
}
开发者ID:jyzhe,项目名称:beehive,代码行数:36,代码来源:server.go

示例3: InstallRoutingOnHive

// InstallRoutingOnHive install the routing application
func InstallRoutingOnHive(h bh.Hive, timeout time.Duration) {
	app := h.NewApp("Routing")
	router := Router{}
	app.Handle(Advertisement{}, router)
	app.Handle(Discovery{}, router)
	app.Handle(Timeout{}, router)
	go func() {
		ticker := time.NewTicker(timeout)
		for {
			<-ticker.C
			h.Emit(Timeout{})
		}
	}()
}
开发者ID:jyzhe,项目名称:beehive,代码行数:15,代码来源:routing.go

示例4: RegisterApps

// RegisterApps registers Kandoo applications on the hive, with the given
// elephant flow size threshold.
func RegisterApps(hive bh.Hive, threshold uint64) {
	ar := hive.NewApp("Reroute")
	ar.Handle(ElephantDetected{}, Rerouter{})

	ad := hive.NewApp("Detect")
	ad.Handle(nom.FlowStatsQueryResult{}, Detector{})
	ad.Handle(nom.NodeJoined{}, Adder{})

	type poll struct{}
	ad.Handle(poll{}, Poller{})
	ad.Detached(bh.NewTimer(1*time.Second, func() {
		hive.Emit(poll{})
	}))
}
开发者ID:dknyxh,项目名称:beehive-netctrl,代码行数:16,代码来源:bh.go

示例5: RegisterDiscovery

// RegisterDiscovery registers the handlers for topology discovery on the hive.
func RegisterDiscovery(h bh.Hive) {
	a := h.NewApp("discovery")
	a.Handle(nom.NodeJoined{}, &nodeJoinedHandler{})
	a.Handle(nom.NodeLeft{}, &nodeLeftHandler{})
	a.Handle(nom.PortUpdated{}, &portUpdateHandler{})
	// TODO(soheil): Handle PortRemoved.
	a.Handle(nom.PacketIn{}, &pktInHandler{})
	a.Handle(NewLink{}, &newLinkHandler{})
	a.Handle(lldpTimeout{}, &timeoutHandler{})
	go func() {
		for {
			h.Emit(lldpTimeout{})
			time.Sleep(60 * time.Second)
		}
	}()
}
开发者ID:jaminp,项目名称:beehive-netctrl,代码行数:17,代码来源:discovery.go

示例6: RegisterNOMController

func RegisterNOMController(h bh.Hive) {
	app := h.NewApp("NOMController", bh.Persistent(3))

	app.Handle(nom.NodeConnected{}, nodeConnectedHandler{})
	app.Handle(nom.NodeDisconnected{}, nodeDisconnectedHandler{})
	app.Handle(nom.PortStatusChanged{}, portStatusHandler{})

	app.Handle(nom.AddFlowEntry{}, addFlowHandler{})
	app.Handle(nom.DelFlowEntry{}, delFlowHandler{})

	app.Handle(nom.FlowStatsQuery{}, queryHandler{})

	app.Handle(nom.PacketOut{}, pktOutHandler{})

	app.Handle(nom.AddTrigger{}, addTriggerHandler{})

	app.Handle(nom.FlowStatsQueryResult{}, Consolidator{})
	app.Handle(nom.Pong{}, HealthChecker{})
	app.Handle(poll{}, Poller{})
	app.Detached(bh.NewTimer(1*time.Second, func() {
		h.Emit(poll{})
	}))
}
开发者ID:dknyxh,项目名称:beehive-netctrl,代码行数:23,代码来源:ctrl.go


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