Skip to content

Commit

Permalink
refactor: Merge the initialized NewClient
Browse files Browse the repository at this point in the history
  • Loading branch information
daviderli614 committed Sep 11, 2024
1 parent fa24df2 commit 0ad184e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,13 @@ func NewClient(cfg *Config) (*Client, error) {
}

client := gpb.NewGreptimeDatabaseClient(conn)
return &Client{cfg: cfg, client: client}, nil
}

// NewHealthCheckClient helps to create the health check client, which will be responsible checking GreptimeDB health status.
func NewHealthCheckClient(cfg *Config) (*Client, error) {
conn, err := grpc.Dial(cfg.endpoint(), cfg.build()...)
if err != nil {
return nil, err
}
healthCheckClient := gpb.NewHealthCheckClient(conn)

client := gpb.NewHealthCheckClient(conn)
return &Client{cfg: cfg, healthCheckClient: client}, nil
return &Client{
cfg: cfg,
client: client,
healthCheckClient: healthCheckClient,
}, nil
}

// submit is to build request and send it to GreptimeDB.
Expand Down
2 changes: 1 addition & 1 deletion examples/healthcheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
func init() {
cfg := greptime.NewConfig("127.0.0.1").WithDatabase("public")

cli_, err := greptime.NewHealthCheckClient(cfg)
cli_, err := greptime.NewClient(cfg)
if err != nil {
log.Panic(err)
}
Expand Down

0 comments on commit 0ad184e

Please sign in to comment.