client.go 601 B

1234567891011121314151617181920212223242526272829
  1. package v1
  2. import (
  3. "context"
  4. "go-common/library/net/rpc/warden"
  5. "google.golang.org/grpc"
  6. )
  7. // AppID unique app id for service discovery
  8. const AppID = "live.xuserex"
  9. // Client client
  10. type Client struct {
  11. RoomNoticeClient
  12. }
  13. // NewClient new resource gRPC client
  14. func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (*Client, error) {
  15. client := warden.NewClient(cfg, opts...)
  16. conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
  17. if err != nil {
  18. return nil, err
  19. }
  20. cli := &Client{}
  21. cli.RoomNoticeClient = NewRoomNoticeClient(conn)
  22. return cli, nil
  23. }