Skip to content

Commit

Permalink
Add health check service (#3)
Browse files Browse the repository at this point in the history
Also improve exception/error handling
  • Loading branch information
miguelbranco80 authored Sep 17, 2024
1 parent e9afda5 commit 6f3fb4f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ lazy val strictBuildSettings = commonSettings ++ compileSettings ++ buildSetting
)

lazy val root = (project in file("."))
.enablePlugins(BuildInfoPlugin)
.settings(
name := "das-server-scala",
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion),
buildInfoPackage := "com.rawlabs.das.server",
strictBuildSettings,
publishSettings,
libraryDependencies ++= Seq(
"com.raw-labs" %% "protocol-das" % "0.1.0" % "compile->compile;test->test",
"com.raw-labs" %% "protocol-das" % "0.1.1" % "compile->compile;test->test",
"com.raw-labs" %% "das-sdk-scala" % "0.1.0" % "compile->compile;test->test"
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2024 RAW Labs S.A.
*
* Use of this software is governed by the Business Source License
* included in the file licenses/BSL.txt.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0, included in the file
* licenses/APL.txt.
*/

package com.rawlabs.das.server

import com.rawlabs.protocol.das.services.{HealthCheckRequest, HealthCheckResponse, HealthCheckServiceGrpc}
import com.typesafe.scalalogging.StrictLogging
import io.grpc.stub.StreamObserver

/**
* gRPC service implementation for health checks.
*/
class HealthCheckServiceGrpcImpl extends HealthCheckServiceGrpc.HealthCheckServiceImplBase with StrictLogging {

/**
* Check the health of the service.
*
* @param request the health check request
* @return the health check response
*/
override def check(request: HealthCheckRequest, responseObserver: StreamObserver[HealthCheckResponse]): Unit = {
responseObserver.onNext(
HealthCheckResponse
.newBuilder()
.setStatus(HealthCheckResponse.ServingStatus.SERVING)
.setDescription(s"Version: ${BuildInfo.version}")
.build()
)
responseObserver.onCompleted()
}

}

0 comments on commit 6f3fb4f

Please sign in to comment.