trpc.group/trpc-go/trpc-go@v1.0.3/naming/discovery/README.md (about)

     1  # Service Discovery
     2  
     3  Service discovery gets service node list by interacting with service registry center.
     4  
     5  ## Usages
     6  Use `client.WithDiscoveryName("xxx")` to specify the service discovery.
     7  ```go
     8  opts := []client.Option{
     9  	client.WithDiscoveryName("xxxx"),
    10  }
    11  proxy := pb.NewGreeterProxy()
    12  req := &pb.HelloRequest{
    13  	Msg: "trpc-go-client",
    14  }
    15  proxy.SayHello(ctx, req, opts...)
    16  ```
    17  
    18  ## Service Discovery Interface
    19  ```go
    20  // Discovery returns node list by service name.
    21  type Discovery interface {
    22  	List(serviceName string, opt ...Option) (nodes []*registry.Node, err error)
    23  }
    24  ```
    25  Refer framework default implementation to how to implement service discovery.