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

Feature/impl deep health check #581

Merged
merged 11 commits into from
Jan 5, 2023
3 changes: 2 additions & 1 deletion internal/infrastructure/dependency/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

type Dependency struct {
DatabaseCli *database.Client

// public
PublicAuthenticationInteractor usecase.PublicAuthenticationInteractor
Expand All @@ -39,7 +40,7 @@ func (d *Dependency) Inject(
ctx context.Context,
e *environment.Environment,
) {
_ = database.NewClient(e.DBHost, e.DBUser, e.DBPassword, e.DBDatabase)
d.DatabaseCli = database.NewClient(e.DBHost, e.DBUser, e.DBPassword, e.DBDatabase)

firebaseCli := firebase.NewClient(e.GCPProjectID)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package public

import (
"github.com/abyssparanoia/rapid-go/internal/infrastructure/database"
public_apiv1 "github.com/abyssparanoia/rapid-go/internal/infrastructure/grpc/pb/rapid/public_api/v1"
"github.com/abyssparanoia/rapid-go/internal/usecase"
)

type PublicHandler struct {
databaseCli *database.Client
public_apiv1.UnimplementedPublicV1ServiceServer
authenticationInteractor usecase.PublicAuthenticationInteractor
tenantInteractor usecase.PublicTenantInteractor
}

func NewPublicHandler(
databaseCli *database.Client,
authenticationInteractor usecase.PublicAuthenticationInteractor,
tenantInteractor usecase.PublicTenantInteractor,
) public_apiv1.PublicV1ServiceServer {
return &PublicHandler{
databaseCli: databaseCli,
authenticationInteractor: authenticationInteractor,
tenantInteractor: tenantInteractor,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package public

import (
"context"

public_apiv1 "github.com/abyssparanoia/rapid-go/internal/infrastructure/grpc/pb/rapid/public_api/v1"
"github.com/abyssparanoia/rapid-go/internal/pkg/logger"
"go.uber.org/zap"
)

func (h *PublicHandler) PublicDeepHealthCheck(ctx context.Context, req *public_apiv1.PublicDeepHealthCheckRequest) (*public_apiv1.PublicDeepHealthCheckResponse, error) {

databaseStatus := "up"
if err := h.databaseCli.DB.Ping(); err != nil {
logger.L(ctx).Error("failed to h.databaseCli.DB.Ping", zap.Error(err))
databaseStatus = "down"
}

return &public_apiv1.PublicDeepHealthCheckResponse{
DatabaseStatus: databaseStatus,
}, nil
}
221 changes: 221 additions & 0 deletions internal/infrastructure/grpc/pb/rapid/public_api/v1/health_check.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading