コード例 #1
0
ファイル: test.go プロジェクト: babelrpc/lib-go
func main() {

	// Register the first service
	floatSvc := new(math.FloatService)
	floatSvc.SvcObj = new(impl.FloatServiceImpl)
	babel.Register(floatSvc)

	// Register the second service
	fractSvc := new(math.FractionService)
	fractSvc.SvcObj = new(impl.FractionServiceImpl)
	babel.Register(fractSvc)

	// Set some info for the monitoring page
	kubismus.Setup("Math Service", "")
	kubismus.Note("Babel base path", "http://localhost:9999"+babel.DefaultHttpPath)
	kubismus.Note("Monitoring path", "http://localhost:9999"+kubismus.DefaultPath)
	kubismus.Note("Test harness path", "http://localhost:9999/test/")
	kubismus.Define("Requests", kubismus.COUNT, "Requests/sec")

	// Set up Babel HTTP handlers and serve HTTP
	http.Handle(babel.DefaultHttpPath, kubismus.HttpRequestMetric("Requests", babel.DefaultServer))
	kubismus.HandleHTTP()
	http.HandleFunc("/test/", harness.ServeHTTP)
	http.HandleFunc("/", frame)
	log.Fatal(http.ListenAndServe(":9999", nil))
}
コード例 #2
0
ファイル: test.go プロジェクト: babelrpc/lib-go
func main() {
	// Register the first service
	floatSvc := new(math.FloatService)
	floatSvc.SvcObj = new(impl.FloatServiceImpl)
	babel.Register(floatSvc)

	// Register the second service
	fractSvc := new(math.FractionService)
	fractSvc.SvcObj = new(impl.FractionServiceImpl)
	babel.Register(fractSvc)

	// Set up Babel HTTP handlers and serve HTTP
	babel.HandleHTTP()
	log.Fatal(http.ListenAndServe(":9999", nil))
}
コード例 #3
0
ファイル: babjs.go プロジェクト: babelrpc/lib-go
func main() {
	// Create Babel service objects
	svc := new(gen.UserService)
	svc.SvcObj = NewUserServiceImpl()

	// Register the service with RPC
	rpc.Register(svc)

	// Register the service with Babel
	babel.Register(svc)

	// Set up Babel HTTP handlers and serve HTTP
	babel.HandleHTTP()
	http.Handle("/test/", http.StripPrefix("/test/", http.FileServer(http.Dir("../test"))))
	go func() { log.Fatal(http.ListenAndServe(":8333", nil)) }()

	//rpc.HandleHTTP(rpc.DefaultRPCPath, rpc.DefaultDebugPath)

	// set up network listener for json rpc
	l, e := net.Listen("tcp", ":8222")
	if e != nil {
		log.Fatal("listen error:", e)
	}

	for {
		conn, err := l.Accept()
		if err != nil {
			log.Fatal(err)
		}

		go jsonrpc.ServeConn(conn)
	}
}