Skip to content
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: Healthcheck endpoints in deploy #37

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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] =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need 3 endpoints if all of them do exactly same thing for now?
(I don't have a strong preference) but I think it would make more sense to add more endpoints if and when we need them (we can start with just one)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one advantage of 3 endpoints is that external users can hook up their startup/readiness/liveness probes to the endpoins and if we want to have different implementation in the future, they just upgrade, no need to change their helmrelease/whatever deployment.

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