如何在golang grpc服务器启动上添加钩子?

如何在golang grpc服务器启动上添加钩子?

问题描述:

是否可以在调用Serve()方法之后添加钩子?

Is it possible to add hook just after Serve() method is called?

grpcServer := grpc.NewServer(options)
if err := grpcServer.Serve(newListener("localhost:1234"); err != nil {
    log.Fatalf("failed to serve: %s", err)
}

我需要知道它的确切运行时间,以便能够从测试客户端调用它.

I need to know when exactly its up and running to be able to call it from tests clients.

我没有在服务器端找到有关启动事件的侦听器;而且我认为没有必要监听此事件,正确的方法是在客户端远程登录服务器地址和端口,以等待服务器准备就绪.

I didn't found listener in server side about startup event; And I think there is no sense to listen this event, the right way is to telnet the server address and port in client side for waitting server ready.