Create & Init Project...
This commit is contained in:
27
app/service/live/dao-anchor/api/grpc/v1/client.go
Normal file
27
app/service/live/dao-anchor/api/grpc/v1/client.go
Normal file
@ -0,0 +1,27 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"go-common/library/net/rpc/warden"
|
||||
)
|
||||
|
||||
const AppID = "live.daoanchor"
|
||||
|
||||
type Client struct {
|
||||
DaoAnchorClient
|
||||
}
|
||||
|
||||
// NewClient new anchor grpc client
|
||||
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (*Client, error) {
|
||||
client := warden.NewClient(cfg, opts...)
|
||||
conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cli := &Client{}
|
||||
cli.DaoAnchorClient = NewDaoAnchorClient(conn)
|
||||
return cli, nil
|
||||
}
|
Reference in New Issue
Block a user