Skip to content

Commit

Permalink
chore: Upgrade to scala 3.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rlemaitre committed Jan 26, 2025
1 parent 95035b6 commit e448fce
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
5 changes: 4 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ ThisBuild / tlCiDependencyGraphJob := true
ThisBuild / autoAPIMappings := true

lazy val sharedSettings = Seq(
scalaVersion := "3.5.2",
scalaVersion := versions.scala,
scalacOptions ++= Seq(
"-source:3.5"
),
libraryDependencies ++= Seq(
"org.scalameta" %% "munit" % versions.munit.core % Test
),
Expand Down
26 changes: 13 additions & 13 deletions modules/core/src/main/scala/pillars/Metrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ object Metrics:
"http.response.status" -> {
case Right(r) =>
r.code match
case c if c.isInformational => "1xx"
case c if c.isSuccess => "2xx"
case c if c.isRedirect => "3xx"
case c if c.isClientError => "4xx"
case c if c.isServerError => "5xx"
case _ => ""
case Left(_) => "5xx"
case c if c.isInformational => "1xx".some
case c if c.isSuccess => "2xx".some
case c if c.isRedirect => "3xx".some
case c if c.isClientError => "4xx".some
case c if c.isServerError => "5xx".some
case _ => None
case Left(_) => "5xx".some
},
"http.response.status_code" -> {
case Right(r) => r.code.toString
case Left(_) => "500"
case Right(r) => r.code.toString.some
case Left(_) => "500".some
},
"error.type" -> {
case Left(ex: PillarsError) => ex.code
case Left(ex) => ex.getClass.getName
case _ => ""
case Left(ex: PillarsError) => ex.code.some
case Left(ex) => ex.getClass.getName.some
case _ => None
}
)
)
Expand Down Expand Up @@ -248,7 +248,7 @@ object Metrics:
private def asOpenTelemetryAttributes(res: Either[Throwable, ServerResponse[?]], phase: Option[String]) =
val attributes = labels.forResponse
.foldLeft(List.empty[Attribute[String]]): (b, label) =>
b :+ Attribute(AttributeKey.string(label._1), label._2(res))
b :+ Attribute(AttributeKey.string(label._1), label._2(res).getOrElse(""))
phase match
case Some(value) => attributes :+ Attribute(AttributeKey.string(labels.forResponsePhase.name), value)
case None => attributes
Expand Down
1 change: 1 addition & 0 deletions modules/core/src/main/scala/pillars/graph.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ object graph:
Left(GraphError.MissingDependency(missing))
else
loop(items, List.empty, Set.empty, Set.empty)
end extension

enum GraphError(val number: ErrorNumber) extends PillarsError:
override def code: Code = Code("GRAPH")
Expand Down
12 changes: 8 additions & 4 deletions modules/core/src/main/scala/pillars/probes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import pillars.probes.endpoints.*
import pillars.probes.views.CheckStatus
import pillars.probes.views.HealthStatus
import scala.concurrent.duration.*
import sttp.model.*
import sttp.model.StatusCode
import sttp.tapir.Endpoint
import sttp.tapir.Schema
import sttp.tapir.given
import sttp.tapir.json.circe.jsonBody
Expand Down Expand Up @@ -155,13 +156,16 @@ object probes:

object endpoints:
private val prefix = baseEndpoint.in("probes")
def liveness = prefix.get.in("healthz").description("Liveness probe").out(stringBody)
def readiness =
def liveness =
prefix.get.in("healthz").description("Liveness probe").out(stringBody)

def readiness =
prefix.get
.in("health")
.description("Readiness probe")
.out(jsonBody[HealthStatus])
def all = List(liveness, readiness)

def all = List(liveness, readiness)
end endpoints
object views:
final case class HealthStatus(status: Status, checks: List[CheckStatus]) derives Codec.AsObject, Schema
Expand Down
6 changes: 4 additions & 2 deletions modules/flags/src/main/scala/pillars/flags/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import sttp.tapir.codec.iron.*
import sttp.tapir.codec.iron.given

package object flags:
given Encoder[Status] = Encoder.encodeString.contramap:
given Encoder[Status] = Encoder.encodeString.contramap {
case Status.Enabled => "enabled"
case Status.Disabled => "disabled"
}

given Decoder[Status] = Decoder.decodeString.emap:
given Decoder[Status] = Decoder.decodeString.emap {
case "enabled" => Right(Status.Enabled)
case "disabled" => Right(Status.Disabled)
case other => Left(s"Invalid status $other")
}

given Schema[Status] = Schema.derived

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final case class Redis[F[_]: MonadCancelThrow](config: RedisConfig, connection:
val probe = new Probe[F]:
override def component: Component = Component(Component.Name("redis"), Component.Type.Datastore)
override def check: F[Boolean] = connection.use { client =>
RedisCommands.ping[io.chrisdavenport.rediculous.Redis[F, *]].run(client) map {
RedisCommands.ping[io.chrisdavenport.rediculous.Redis[F, *]].run(client).map {
case Ok | Pong => true
case _ => false
}
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sbt.*

object versions {
val scala = "3.5.2"
val scala = "3.6.3"
// Dependencies
val cats = "2.13.0"
val catsEffect = "3.5.7"
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.7.5")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.7.7")
// Build
addSbtPlugin("com.timushev.sbt" % "sbt-rewarn" % "0.1.3")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1")
Expand Down

0 comments on commit e448fce

Please sign in to comment.