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


Golang beehive.Hive类代码示例

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


在下文中一共展示了Hive类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
开发者ID:1995parham,项目名称:FlyNest,代码行数:7,代码来源:bh.go

示例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{})
}
开发者ID:1995parham,项目名称:FlyNest,代码行数:29,代码来源:bh.go

示例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
}
开发者ID:jyzhe,项目名称:beehive,代码行数:36,代码来源:server.go

示例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{})
}
开发者ID:1995parham,项目名称:FlyNest,代码行数:9,代码来源:bh.go

示例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{})
		}
	}()
}
开发者ID:jyzhe,项目名称:beehive,代码行数:15,代码来源:routing.go

示例6: 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

示例7: 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
}
开发者ID:1995parham,项目名称:FlyNest,代码行数:20,代码来源:bh.go

示例8: defaultHTTPHandler

func defaultHTTPHandler(w http.ResponseWriter, r *http.Request, h bh.Hive) {
	w.Header().Set("Server", "Beehive-netctrl-HTTP-Server")

	vars := mux.Vars(r)

	submodule, ok := vars["submodule"]
	if !ok {
		/* This should not happened :) */
		http.Error(w, "Invalid request", http.StatusBadRequest)
		return
	}

	verb, ok := vars["verb"]
	if !ok {
		/* This should not happened :) */
		http.Error(w, "Invalid request", http.StatusBadRequest)
		return
	}

	creq := HTTPRequest{
		AppName: submodule,
		Verb:    verb,
	}

	// Read content data if available :)
	if r.ContentLength > 0 {
		data, err := ioutil.ReadAll(r.Body)
		if err == nil {
			creq.Data = data
		}
	}

	cres, err := h.Sync(context.TODO(), creq)
	if err == nil && cres != nil {
		w.Write(cres.(HTTPResponse).Data)
		w.WriteHeader(http.StatusOK)
		return
	} else {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		fmt.Errorf("defaultTTPHandler: %v\n", err)
		return
	}

}
开发者ID:1995parham,项目名称:FlyNest,代码行数:44,代码来源:handle.go

示例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{})
	}))
}
开发者ID:dknyxh,项目名称:beehive-netctrl,代码行数:23,代码来源:ctrl.go

示例10: 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

示例11: 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{})
}
开发者ID:jaminp,项目名称:beehive-netctrl,代码行数:6,代码来源:learning.go

示例12: 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{})
}
开发者ID:jaminp,项目名称:beehive-netctrl,代码行数:6,代码来源:hub.go


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