Health check doesn't implement grpc health protocol
eugkhp opened this issue · 1 comments
eugkhp commented
I'm trying to use health check #626 feature. But I can't figure out a way to check service status.
I'm using https://github.com/grpc-ecosystem/grpc-health-probe/ cli program, but and when I run it, it says:
/grpc_health_probe-linux-amd64 --addr=0.0.0.0:50051 -v
parsed options:
> addr=0.0.0.0:50051 conn_timeout=1s rpc_timeout=1s
> tls=false
establishing connection
connection established (took 229.529469ms)
error: this server does not implement the grpc health protocol (grpc.health.v1.Health)
either on my own service:
implicit0(hc: HealthCheckServiceFS2[F]) <- HealthServiceFS2.buildInstance[F]
healthCheck <- HealthCheckServiceFS2.bindService[F]
endpoints = List(
...
AddService(healthCheck)
)
server <- GrpcServer.default[F](r.config.rpcPort, endpoints)
_ <- info"Gateway Starting"
_ <- List(GatewayHttpEndpoint.launch(...),
GrpcServer.server[F](server)
).parTraverse_(identity)
or on example (https://github.com/higherkindness/mu-scala-examples/tree/master/health-check) server:
sbt health-server-fs2/run
[info] Loading global plugins from /home/user/.sbt/1.0/plugins
[info] Loading settings for project mu-scala-examples-build from plugins.sbt ...
[info] Loading project definition from /home/user/IdeaProjects/mu-scala-examples/project
[info] Loading settings for project root from build.sbt,version.sbt ...
[info] Resolving key references (22777 settings) ...
[info] Set current project to mu-scala-examples (in build file:/home/user/IdeaProjects/mu-scala-examples/)
[info] running higherkindness.mu.rpc.healthcheck.sFs2.ServerApp
Am I doing something wrong? Or it doesn't support "default" healthcheck?
eugkhp commented
By the way, if I make some naive implementation like this:
class HealthSvc[F[_]: MonadError[*[_], Throwable]: Logging: Timer: Sync] extends Health[F] {
val E = MonadError[F, Throwable]
val L = Logging[F]
override def Check(req: HealthCheckRequest): F[HealthCheckResponse] = {
HealthCheckResponse(Some(ServingStatus.SERVING)).pure[F]
}
override def Watch(req: HealthCheck.HealthCheckRequest): F[fs2.Stream[F, HealthCheckResponse]] = {
Sync[F].delay(
fs2.Stream.fixedRate(5 seconds).evalMap(_ => HealthCheckResponse(Some(ServingStatus.SERVING)).pure[F])
)
}
}
it works like a charm:
./grpc_health_probe-linux-amd64 --addr=0.0.0.0:50051 -v
parsed options:
> addr=0.0.0.0:50051 conn_timeout=1s rpc_timeout=1s
> tls=false
establishing connection
connection established (took 117.100079ms)
time elapsed: connect=117.100079ms rpc=50.927594ms
status: SERVING
Did I misunderstood the feature?