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

refactor: Merge the initialized NewClient #46

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
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
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
Loading