本文整理汇总了Golang中github.com/kandoo/beehive.Hive.NewApp方法的典型用法代码示例。如果您正苦于以下问题:Golang Hive.NewApp方法的具体用法?Golang Hive.NewApp怎么用?Golang Hive.NewApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/kandoo/beehive.Hive
的用法示例。
在下文中一共展示了Hive.NewApp方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StartTest
func StartTest(hive bh.Hive) error {
app := hive.NewApp("TestApp")
fmt.Println("Test app is comming ... :)))")
app.HandleFunc(nom.HostJoined{}, bh.RuntimeMap(hostJoinedRcvf), hostJoinedRcvf)
return nil
}
示例2: 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{})
}
示例3: 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
}
示例4: RegisterIntent
func RegisterIntent(h bh.Hive) {
a := h.NewApp("intent")
a.Handle(nom.LinkAdded{}, &discovery.GraphBuilderCentralized{})
a.Handle(nom.LinkDeleted{}, &discovery.GraphBuilderCentralized{})
http.NewHTTPApp(a, h).DefaultHandle()
a.Handle(http.HTTPRequest{}, &intentHandler{})
}
示例5: 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{})
}
}()
}
示例6: 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{})
}))
}
示例7: 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)
}
}()
}
示例8: StartOpenFlow
// StartOpenFlow starts the OpenFlow driver on the given hive using the default
// OpenFlow configuration that can be set through command line arguments.
func StartOpenFlow(hive bh.Hive, options ...Option) error {
app := hive.NewApp("OFDriver",
bh.OutRate(bucket.Rate(*maxConnRate), 10*uint64(*maxConnRate)))
l := &ofListener{
proto: *proto,
addr: *addr,
readBufLen: *readBufLen,
}
for _, opt := range options {
opt(l)
}
app.Detached(l)
glog.V(2).Infof("OpenFlow driver registered on %s:%s", l.proto, l.addr)
return nil
}
示例9: 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{})
}))
}
示例10: RegisterSwitch
// RegisterSwitch registers the learning switch application on the given
// hive with the provided options.
func RegisterSwitch(h bh.Hive, opts ...bh.AppOption) {
app := h.NewApp("Switch", opts...)
app.Handle(nom.PacketIn{}, LearningSwitch{})
}
示例11: RegisterHub
// RegisterHub registers the hub application on the given
// hive with the provided options.
func RegisterHub(h bh.Hive, opts ...bh.AppOption) {
app := h.NewApp("Hub", opts...)
app.Handle(nom.PacketIn{}, Hub{})
}