func main()

in rpc/multi-protocols/go-server/cmd/main.go [45:100]


func main() {
	ins, err := dubbo.NewInstance(
		dubbo.WithName("dubbo_multirpc_server"),
		dubbo.WithRegistry(
			registry.WithZookeeper(),
			registry.WithAddress("127.0.0.1:2181"),
		),
		dubbo.WithProtocol(
			protocol.WithTriple(),
			protocol.WithPort(20000)),
		dubbo.WithProtocol(
			protocol.WithDubbo(),
			protocol.WithPort(20001)),
		dubbo.WithProtocol(
			protocol.WithJSONRPC(),
			protocol.WithPort(20002)),
	)
	if err != nil {
		panic(err)
	}
	//Triple
	srvTriple, err := ins.NewServer()
	if err != nil {
		panic(err)
	}
	if err = greet2.RegisterGreetServiceHandler(srvTriple, &GreetMultiRPCServer{}); err != nil {
		panic(err)
	}
	if err = srvTriple.Serve(); err != nil {
		logger.Error(err)
	}

	//Dubbo
	srvDubbo, err := ins.NewServer()
	if err != nil {
		panic(err)
	}
	if err = srvDubbo.Register(&GreetProvider{}, nil, server.WithInterface("GreetProvider")); err != nil {
		panic(err)
	}
	if err = srvDubbo.Serve(); err != nil {
		logger.Error(err)
	}

	//JsonRpc
	srvJsonRpc, err := ins.NewServer()
	if err != nil {
		panic(err)
	}
	if err = srvJsonRpc.Register(&GreetProvider{}, nil, server.WithInterface("GreetProvider")); err != nil {
		panic(err)
	}
	if err := srvJsonRpc.Serve(); err != nil {
		logger.Error(err)
	}
}