Skip to content

Commit

Permalink
Merge pull request #47 from kqzh/add_close
Browse files Browse the repository at this point in the history
feat: add close
  • Loading branch information
kqzh authored Oct 8, 2023
2 parents 2e7108b + 0c74539 commit b6158a1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Client interface {
StopAgent(req *pb.StopAgentRequest) (*pb.StopAgentResponse, error)
HealthCheck(req *pb.HealthCheckRequest) (*pb.HealthCheckResponse, error)
GetSpaceUsages(req *pb.GetSpaceUsagesRequest) (*pb.GetSpaceUsagesResponse, error)
Close() error
}

func genSessionId() string {
Expand All @@ -43,6 +44,7 @@ func genSessionId() string {
type client struct {
ctx context.Context
addr *nebula.HostAddr
conn *grpc.ClientConn
storage pb.StorageServiceClient
agent pb.AgentServiceClient
}
Expand All @@ -62,13 +64,18 @@ func New(ctx context.Context, cfg *Config) (Client, error) {
c := &client{
ctx: ctx,
addr: cfg.Addr,
conn: conn,
storage: pb.NewStorageServiceClient(conn),
agent: pb.NewAgentServiceClient(conn),
}

return c, nil
}

func (c *client) Close() error {
return c.conn.Close()
}

func (c *client) GetAddr() *nebula.HostAddr {
return c.addr
}
Expand Down

0 comments on commit b6158a1

Please sign in to comment.