Skip to content

Commit

Permalink
Rename health check package and function names
Browse files Browse the repository at this point in the history
Rename for consistency
  • Loading branch information
taeng0204 committed Aug 7, 2024
1 parent 932cf62 commit 18e682c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

// Package health uses http GET to provide a health check for the server.
package health
// Package httphealth uses http GET to provide a health check for the server.
package httphealth

import (
"encoding/json"
Expand All @@ -29,8 +29,8 @@ type CheckResponse struct {
Status string `json:"status"`
}

// NewHTTPHandler creates a new HTTP handler for health checks.
func NewHTTPHandler(checker grpchealth.Checker) (string, http.Handler) {
// NewHandler creates a new HTTP handler for health checks.
func NewHandler(checker grpchealth.Checker) (string, http.Handler) {
const serviceName = "/healthz/"
check := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
Expand Down
4 changes: 2 additions & 2 deletions server/rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/yorkie-team/yorkie/server/backend"
"github.com/yorkie-team/yorkie/server/logging"
"github.com/yorkie-team/yorkie/server/rpc/auth"
"github.com/yorkie-team/yorkie/server/rpc/health"
"github.com/yorkie-team/yorkie/server/rpc/httphealth"
"github.com/yorkie-team/yorkie/server/rpc/interceptors"
)

Expand Down Expand Up @@ -74,7 +74,7 @@ func NewServer(conf *Config, be *backend.Backend) (*Server, error) {
mux.Handle(v1connect.NewYorkieServiceHandler(newYorkieServer(yorkieServiceCtx, be), opts...))
mux.Handle(v1connect.NewAdminServiceHandler(newAdminServer(be, tokenManager), opts...))
mux.Handle(grpchealth.NewHandler(healthChecker))
mux.Handle(health.NewHTTPHandler(healthChecker))
mux.Handle(httphealth.NewHandler(healthChecker))
// TODO(hackerwins): We need to provide proper http server configuration.
return &Server{
conf: conf,
Expand Down
6 changes: 3 additions & 3 deletions test/integration/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"connectrpc.com/grpchealth"
"github.com/stretchr/testify/assert"
"github.com/yorkie-team/yorkie/api/yorkie/v1/v1connect"
"github.com/yorkie-team/yorkie/server/rpc/health"
"github.com/yorkie-team/yorkie/server/rpc/httphealth"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
healthpb "google.golang.org/grpc/health/grpc_health_v1"
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestHTTPHealthCheck(t *testing.T) {
}()
assert.Equal(t, resp.StatusCode, http.StatusOK)

var healthResp health.CheckResponse
var healthResp httphealth.CheckResponse
err = json.NewDecoder(resp.Body).Decode(&healthResp)
assert.NoError(t, err)
assert.Equal(t, healthResp.Status, grpchealth.StatusServing.String())
Expand All @@ -106,7 +106,7 @@ func TestHTTPHealthCheck(t *testing.T) {
}()
assert.Equal(t, resp.StatusCode, http.StatusOK)

var healthResp health.CheckResponse
var healthResp httphealth.CheckResponse
err = json.NewDecoder(resp.Body).Decode(&healthResp)
assert.NoError(t, err)
assert.Equal(t, healthResp.Status, grpchealth.StatusServing.String())
Expand Down

0 comments on commit 18e682c

Please sign in to comment.