0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-12 11:29:36 +03:00

Add h2 & gRPC health check

This commit is contained in:
hmol233
2021-07-03 16:01:59 +08:00
parent d45298a10d
commit d9d04a230f
8 changed files with 162 additions and 83 deletions

View File

@ -7,10 +7,23 @@ import (
)
type GRPCConfig struct {
ServiceName string `json:"serviceName"`
MultiMode bool `json:"multiMode"`
ServiceName string `json:"serviceName" `
MultiMode bool `json:"multiMode"`
IdleTimeout int32 `json:"idle_timeout"`
HealthCheckTimeout int32 `json:"health_check_timeout"`
}
func (g GRPCConfig) Build() (proto.Message, error) {
return &grpc.Config{ServiceName: g.ServiceName, MultiMode: g.MultiMode}, nil
func (g *GRPCConfig) Build() (proto.Message, error) {
if g.IdleTimeout <= 0 {
g.IdleTimeout = 0
}
if g.HealthCheckTimeout <= 0 {
g.HealthCheckTimeout = 0
}
return &grpc.Config{
ServiceName: g.ServiceName,
MultiMode: g.MultiMode,
IdleTimeout: g.IdleTimeout,
HealthCheckTimeout: g.HealthCheckTimeout,
}, nil
}