-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(transport/grpc): support custom healthcheck #2541
feat(transport/grpc): support custom healthcheck #2541
Conversation
You can use it as an extension configuration instead of a default parameter. Your modifications introduce incompatible changes. |
Codecov Report
@@ Coverage Diff @@
## main #2541 +/- ##
==========================================
- Coverage 85.23% 85.16% -0.07%
==========================================
Files 88 88
Lines 3826 3830 +4
==========================================
+ Hits 3261 3262 +1
- Misses 391 394 +3
Partials 174 174
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@shenqidebaozi It's better now ? :) // NewGRPCServer new a gRPC server.
func NewGRPCServer(c *conf.Server, greeter *service.SplitsService, ghealth *service.HealthService, logger hclog.Logger) *grpc.Server {
var (
log hclog.Logger = logger.Named("NewGRPCServer")
opts = []grpc.ServerOption{
grpc.CustomHealth(),
grpc.Middleware(
metadata.Server(),
recovery.Recovery(),
validate.Validator(),
metrics.Server(
metrics.WithSeconds(prom.NewHistogram(_metricSeconds)),
metrics.WithRequests(prom.NewCounter(_metricRequests)),
),
),
}
)
if c.Grpc.Network != "" {
opts = append(opts, grpc.Network(c.Grpc.Network))
}
if c.Grpc.Hostname != "" {
opts = append(opts, grpc.Address(c.Grpc.Hostname))
}
if c.Grpc.Timeout != nil {
opts = append(opts, grpc.Timeout(c.Grpc.Timeout.AsDuration()))
}
srv := grpc.NewServer(opts...)
srv.Use("/splits.v1.Splits/*", auth.MiddlewareOptions(log, c.Keycloak))
srv.Use("/grpc.health.v1.Health/*")
v1.RegisterSplitsServer(srv, greeter)
grpc_health_v1.RegisterHealthServer(srv, ghealth)
return srv
} |
@perriea This looks good. Can you submit it as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* feat(transport/grpc): support custom healthcheck * fix: parameters grpc server * fix(transport/grpc): optional CustomHealth * fix(transport/grpc): useless argument
Description (what this PR does / why we need it):
Currently, it is not possible to define custom health checks. This PR should solve that.
Which issue(s) this PR fixes (resolves / be part of):
resolves #1397