Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add close #47

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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