Пример #1
0
func main() {
	ctx := context.NewContext()

	currentServerInfo := make(map[string]interface{})

	currentServerInfo["host"] = "127.0.0.1"
	currentServerInfo["port"] = 8888

	ctx.CurrentServer = currentServerInfo
	client := rpcclient.NewRpcClient(ctx)

	seelog.Errorf("Error,this is just for test")

	var reply string
	callRst := client.RpcCall("self", "Echo.Hi", "Eric", &reply)

	if callRst == nil {
		log.Fatal("What F**k")
	}
	<-callRst.Done

	if callRst.Error != nil {
		log.Fatal(callRst.Error.Error())
	}

	fmt.Printf("Reply is : %v\n", *callRst.Reply.(*string))
}
Пример #2
0
func main() {
	ctx := context.NewContext()
	ctx.MasterInfo["id"] = "master"
	ctx.MasterInfo["host"] = "127.0.0.1"
	ctx.MasterInfo["port"] = 8888

	ctx.CurrentServer["serverType"] = "connector"
	ctx.CurrentServer["id"] = "connector-1"
	ctx.CurrentServer["host"] = "192.168.1.2"
	ctx.CurrentServer["port"] = 8889
	ctx.CurrentServer["clientPort"] = 8889
	ctx.CurrentServer["frontend"] = "false"

	ri, err := reportInfo.NewReportInfo("reportInfo", "push", 5, "127.0.0.1", 6379)

	if err != nil {
		log.Fatal(err.Error())
	}

	ctx.RegisteModule(ri)
	ch := make(chan int)

	mcs := pomelo_admin.NewMonitorConsoleService(ctx)
	mcs.Start()
	select {
	case <-ch:
	}
}
Пример #3
0
func main() {
	if len(os.Args) != 3 {
		log.Fatal("too few args to server,commandline form <command host port>")
	}

	context.NewContext()
	host := os.Args[1]
	port, err := strconv.Atoi(os.Args[2])
	if err != nil {
		log.Fatalf("Fail to convert os.args[2] to port(type int),error message:", err.Error())
	}

	server := rpcserver.NewRpcServer(host, port)
	server.RegisteService(new(Echo))

	server.Start()
}
Пример #4
0
func main() {
	ctx := context.NewContext()
	ctx.MasterInfo["id"] = "master"
	ctx.MasterInfo["host"] = "127.0.0.1"
	ctx.MasterInfo["port"] = 8888

	ctx.CurrentServer["id"] = "master-1"
	ctx.CurrentServer["host"] = "192.168.1.2"
	ctx.CurrentServer["port"] = 8889
	ctx.CurrentServer["clientPort"] = 8889
	ctx.CurrentServer["frontend"] = "false"
	ch := make(chan int)

	mcs := pomelo_admin.NewMasterConsoleService(ctx)
	mcs.Start()
	select {
	case <-ch:
	}
}