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 }
func Example_hTTP() { // Create the hello world application and make sure . app := beehive.NewApp("hello-world", beehive.Persistent(1)) // Register the handler for Hello messages. app.HandleFunc(HelloHTTP{}, beehive.RuntimeMap(RcvfHTTP), RcvfHTTP) // Register the HTTP handler for the hello world application. app.HandleHTTP("/{name}", &HelloHTTPHandler{}).Methods("POST") // Start the DefaultHive. beehive.Start() }
func Example_detached() { // Create the hello world application and make sure . app := beehive.NewApp("hello-world", beehive.Persistent(1)) // Register the handler for Hello messages. app.HandleFunc(HelloDetached{}, beehive.RuntimeMap(RcvfDetached), RcvfDetached) // Register the detached handler for the hello world listener. app.Detached(NewHelloListener()) // Start the DefaultHive. beehive.Start() }
func Example() { // Create the hello world application and make sure . app := beehive.NewApp("hello-world", beehive.Persistent(1)) // Register the handler for Hello messages. app.HandleFunc(Hello{}, beehive.RuntimeMap(Rcvf), Rcvf) // Emit simply emits a message, here a // string of your name. go beehive.Emit(Hello{Name: "your name"}) // Emit another message with the same name // to test the counting feature. go beehive.Emit(Hello{Name: "your name"}) // Start the DefualtHive. beehive.Start() }
func main() { logger.InitDefault() logger.Trace.Println("[main] Init beehive app") // Create the application and beehiveApp := beehive.NewApp("beehive-app", beehive.Persistent(0)) // Register the handler for MessageToBee messages. beehiveApp.HandleFunc( MessageToBee{}, beehive.RuntimeMap(BeeHandler), BeeHandler) initHTTPHandler(beehiveApp) logger.Trace.Println("[main] Start beehive") beehive.Start() }
func Example_reply() { // Create the hello world application and make sure . app := beehive.NewApp("hello-world", beehive.Persistent(1)) // Register the handler for Hello messages. app.HandleFunc(HelloReply{}, beehive.RuntimeMap(RcvfReply), RcvfReply) // Start the default hive. go beehive.Start() defer beehive.Stop() name := "your name" for i := 0; i < 2; i++ { // Sync sends the Hello message and waits until it receives the reply. res, err := beehive.Sync(context.TODO(), HelloReply{Name: name}) if err != nil { glog.Fatalf("error in sending Hello: %v", err) } cnt := res.(int) fmt.Printf("hello %s (%d)!\n", name, cnt) } }
func (h *intentHandler) Map(msg bh.Msg, ctx bh.MapContext) bh.MappedCells { return bh.RuntimeMap(h.Rcv)(msg, ctx) }