-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #353 from gatewayd-io/add-healthz-endpoints
Add healthz endpoints
- Loading branch information
Showing
6 changed files
with
96 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gatewayd-io/gatewayd/network" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/health/grpc_health_v1" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
type HealthChecker struct { | ||
grpc_health_v1.UnimplementedHealthServer | ||
|
||
Servers map[string]*network.Server | ||
} | ||
|
||
func (h *HealthChecker) Check( | ||
context.Context, *grpc_health_v1.HealthCheckRequest, | ||
) (*grpc_health_v1.HealthCheckResponse, error) { | ||
// Check if all servers are running | ||
if liveness(h.Servers) { | ||
return &grpc_health_v1.HealthCheckResponse{ | ||
Status: grpc_health_v1.HealthCheckResponse_SERVING, | ||
}, nil | ||
} | ||
|
||
return &grpc_health_v1.HealthCheckResponse{ | ||
Status: grpc_health_v1.HealthCheckResponse_NOT_SERVING, | ||
}, nil | ||
} | ||
|
||
func (h *HealthChecker) Watch( | ||
*grpc_health_v1.HealthCheckRequest, | ||
grpc_health_v1.Health_WatchServer, | ||
) error { | ||
return status.Error(codes.Unimplemented, "not implemented") //nolint:wrapcheck | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/gatewayd-io/gatewayd/network" | ||
) | ||
|
||
func liveness(servers map[string]*network.Server) bool { | ||
for _, v := range servers { | ||
if !v.IsRunning() { | ||
return false | ||
} | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters