-
Notifications
You must be signed in to change notification settings - Fork 11
/
client.go
36 lines (28 loc) · 748 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package v1
import (
"google.golang.org/grpc"
epclient "github.com/ClessLi/bifrost/pkg/client/bifrost/v1/endpoint"
svcclient "github.com/ClessLi/bifrost/pkg/client/bifrost/v1/service"
txpclient "github.com/ClessLi/bifrost/pkg/client/bifrost/v1/transport"
)
type Client struct {
conn *grpc.ClientConn
svcclient.Factory
}
func (c *Client) Close() error {
return c.conn.Close()
}
func newClient(conn *grpc.ClientConn) *Client {
return &Client{
conn: conn,
Factory: svcclient.New(epclient.New(txpclient.New(conn))),
}
}
func New(svraddr string, opts ...grpc.DialOption) (*Client, error) {
conn, err := grpc.Dial(svraddr, opts...)
if err != nil {
return nil, err
}
return newClient(conn), nil
}
// TODO: NewClientFromConsul