diff --git a/pkg/client/client.go b/pkg/client/client.go index fc1a3a6..c7ffcf9 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -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 { @@ -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 } @@ -62,6 +64,7 @@ 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), } @@ -69,6 +72,10 @@ func New(ctx context.Context, cfg *Config) (Client, error) { return c, nil } +func (c *client) Close() error { + return c.conn.Close() +} + func (c *client) GetAddr() *nebula.HostAddr { return c.addr }