Skip to content

Commit

Permalink
Feat: Add health check endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Hall <[email protected]>
  • Loading branch information
j-hall-mwam committed Nov 28, 2023
1 parent ab8295c commit 8e705a2
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,25 @@ class Endpoints(
) {
private val metricsEndpoint: PublicEndpoint[Unit, Unit, String, Any] = endpoint.in("metrics").get.out(stringBody)

// Health check endpoints. As of now, just return 200 no preparation is done
// after the HTTP server starts.
private val livenessEndpoint: PublicEndpoint[Unit, Nothing, Unit, Any] =
infallibleEndpoint.in("health").in("live").get
private val readinessEndpoint: PublicEndpoint[Unit, Nothing, Unit, Any] =
infallibleEndpoint.in("health").in("ready").get
private val startupProbeEndpoint: PublicEndpoint[Unit, Nothing, Unit, Any] =
infallibleEndpoint.in("health").in("startup").get

val endpoints: List[ZServerEndpoint[Any, Any]] = {
val api = deploymentServerEndpoints.endpoints
val docs = docsEndpoints(api)
val metrics = List(metricsEndpoint.zServerLogic[Any](_ => getMetrics))
api ++ docs ++ metrics
val health =
List(livenessEndpoint, readinessEndpoint, startupProbeEndpoint)
.map(
_.zServerLogic[Any](_ => ZIO.succeed(()))
)
api ++ docs ++ metrics ++ health
}

private def docsEndpoints(apiEndpoints: List[ZServerEndpoint[Any, Any]]): List[ZServerEndpoint[Any, Any]] = SwaggerInterpreter()
Expand Down

0 comments on commit 8e705a2

Please sign in to comment.