Skip to content

Commit

Permalink
fix code and set ignore update list in scala-steward
Browse files Browse the repository at this point in the history
Signed-off-by: FabioPinheiro <fabiomgpinheiro@gmail.com>
  • Loading branch information
FabioPinheiro committed Apr 29, 2024
1 parent 24c70b1 commit fa9daff
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .github/.scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ buildRoots = [ "." ]
pullRequests.grouping = [
{ name = "all", title = "build: scala-steward dependency updates", "filter" = [{"group" = "*"}] }
]

updates.ignore = [
{ groupId = "dev.zio", artifactId = "zio-json" }, #TODO
{ groupId = "com.softwaremill.sttp.tapir", artifactId = "tapir-json-zio" }, #TODO
]
7 changes: 4 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ lazy val V = new {
val zioLogging = "2.1.17"
val zioJson = "0.6.2"
val zioHttp = "3.0.0-RC6"
val zioCatsInterop = "23.1.0.2"
val zioCatsInterop = "3.3.0" // TODO "23.1.0.2" // https://mvnrepository.com/artifact/dev.zio/zio-interop-cats
val zioMetricsConnector = "2.3.1"
val zioMock = "1.0.0-RC12"
val mockito = "3.2.18.0"
Expand All @@ -62,7 +62,8 @@ lazy val V = new {
// https://mvnrepository.com/artifact/io.circe/circe-core
val circe = "0.14.7"

val tapir = "1.10.5"
val tapir = "1.6.4" // TODO "1.10.5"
val http4sBlaze = "0.23.15" // TODO "0.23.16"

val typesafeConfig = "1.4.3"
val protobuf = "3.1.9"
Expand Down Expand Up @@ -360,7 +361,7 @@ lazy val D_CloudAgent = new {

val tapirZioHttpServer = "com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % V.tapir
val tapirHttp4sServerZio = "com.softwaremill.sttp.tapir" %% "tapir-http4s-server-zio" % V.tapir
val http4sBlazeServer = "org.http4s" %% "http4s-blaze-server" % "0.23.16"
val http4sBlazeServer = "org.http4s" %% "http4s-blaze-server" % V.http4sBlaze

val tapirRedocBundle = "com.softwaremill.sttp.tapir" %% "tapir-redoc-bundle" % V.tapir

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ object MediateGrant {
* FIXME https://github.com/roots-id/didcomm-mediator/issues/17
*/
final case class Body(routing_did: String) // Seq[String])

object Body {
given Encoder[Body] = deriveEncoder[Body]
given Decoder[Body] = deriveDecoder[Body]
}
}

final case class KeylistUpdate(id: String, `type`: PIURI, body: KeylistUpdate.Body) {
Expand All @@ -51,6 +56,11 @@ object KeylistUpdate {

final case class Body(updates: Seq[Update])

object Body {
given Encoder[Body] = deriveEncoder[Body]
given Decoder[Body] = deriveDecoder[Body]
}

/** @param recipient_did
* DID subject of the update.
* @param action
Expand All @@ -60,6 +70,10 @@ object KeylistUpdate {
enum Action:
case add extends Action
case remove extends Action
object Action {
given Encoder[Action] = deriveEncoder[Action]
given Decoder[Action] = deriveDecoder[Action]
}
}

final case class KeylistResponse(id: String, `type`: PIURI, body: KeylistResponse.Body) {
Expand All @@ -74,6 +88,11 @@ object KeylistResponse {

final case class Body(updated: Seq[Update])

object Body {
given Encoder[Body] = deriveEncoder[Body]
given Decoder[Body] = deriveDecoder[Body]
}

/** @param recipient_did
* DID subject of the update.
* @param action
Expand All @@ -85,11 +104,20 @@ object KeylistResponse {
enum Action:
case add extends Action
case remove extends Action
object Action {
given Encoder[Action] = deriveEncoder[Action]
given Decoder[Action] = deriveDecoder[Action]
}

enum Result:
case client_error extends Result
case server_error extends Result
case no_change extends Result
case success extends Result
object Result {
given Encoder[Result] = deriveEncoder[Result]
given Decoder[Result] = deriveDecoder[Result]
}
}

final case class KeylistQuery(id: String, `type`: PIURI, body: KeylistQuery.Body) {
Expand All @@ -102,6 +130,14 @@ object KeylistQuery {

final case class Body(paginate: Option[Paginate] = None)
final case class Paginate(limit: Int, offset: Int)
object Body {
given Encoder[Body] = deriveEncoder[Body]
given Decoder[Body] = deriveDecoder[Body]
}
object Paginate {
given Encoder[Paginate] = deriveEncoder[Paginate]
given Decoder[Paginate] = deriveDecoder[Paginate]
}
}

final case class Keylist(id: String, `type`: PIURI, body: Keylist.Body) {
Expand All @@ -117,4 +153,17 @@ object Keylist {
final case class Body(keys: Seq[Key], pagination: Option[Pagination])
final case class Key(recipient_did: String)
final case class Pagination(count: Int, offset: Int, remaining: Int)

object Body {
given Encoder[Body] = deriveEncoder[Body]
given Decoder[Body] = deriveDecoder[Body]
}
object Key {
given Encoder[Key] = deriveEncoder[Key]
given Decoder[Key] = deriveDecoder[Key]
}
object Pagination {
given Encoder[Pagination] = deriveEncoder[Pagination]
given Decoder[Pagination] = deriveDecoder[Pagination]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ object CredentialPreview {

case class CredentialPreviewBody(attributes: Seq[Attribute])

object CredentialPreviewBody {
given Encoder[CredentialPreviewBody] = deriveEncoder[CredentialPreviewBody]
given Decoder[CredentialPreviewBody] = deriveDecoder[CredentialPreviewBody]
}

/** @param name
* name key maps to the attribute name as a string.
* @param media_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ class JdbcCredentialRepository(xa: Transactor[ContextAwareTask], xb: Transactor[
case Nil =>
connection.pure(Nil)
case head +: tail =>
val nel = NonEmptyList.of(head, tail: _*)
val inClauseFragment = Fragments.in(fr"protocol_state", nel)
val conditionFragment = Fragments.andOpt(
Some(inClauseFragment),
Option.when(ignoreWithZeroRetries)(fr"meta_retries > 0")
)
val conditionFragment = {
val nel = NonEmptyList.of(head, tail: _*)
val inClauseFragment = Fragments.in(fr"protocol_state", nel)
if (!ignoreWithZeroRetries) inClauseFragment
else Fragments.and(inClauseFragment, fr"meta_retries > 0")
}
val cxnIO = sql"""
| SELECT
| id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cats.effect.kernel.Resource
import cats.effect.std.Dispatcher
import com.zaxxer.hikari.HikariConfig
import doobie.hikari.HikariTransactor
import doobie.util.ExecutionContexts
import doobie.util.log.LogHandler
import doobie.util.transactor.Transactor
import zio.*
import zio.interop.catz.*
Expand All @@ -17,7 +17,7 @@ object TransactorLayer {
ZIO.service[DbConfig].flatMap { config =>
// Here we use `Dispatcher.apply`
// but at the agent level it is `Dispatcher.parallel` due to evicted version
Dispatcher[Task].allocated.map { case (dispatcher, _) =>
Dispatcher.parallel[Task].allocated.map { case (dispatcher, _) =>
given Dispatcher[Task] = dispatcher
TransactorLayer.hikari[Task](config)
}
Expand All @@ -32,7 +32,7 @@ object TransactorLayer {

// Here we use `Dispatcher.apply`
// but at the agent level it is `Dispatcher.parallel` due to evicted version
Dispatcher[ContextAwareTask].allocated.map { case (dispatcher, _) =>
Dispatcher.parallel[ContextAwareTask].allocated.map { case (dispatcher, _) =>
given Dispatcher[ContextAwareTask] = dispatcher
TransactorLayer.hikari[ContextAwareTask](config)
}
Expand All @@ -41,6 +41,7 @@ object TransactorLayer {
}

def hikari[A[_]: Async: Dispatcher](config: DbConfig)(using tag: Tag[Transactor[A]]): TaskLayer[Transactor[A]] = {

val transactorLayerZio = ZIO
.attempt {
// https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
Expand All @@ -56,8 +57,8 @@ object TransactorLayer {
val pool: Resource[A, Transactor[A]] = for {
// Resource yielding a transactor configured with a bounded connect EC and an unbounded
// transaction EC. Everything will be closed and shut down cleanly after use.
ec <- ExecutionContexts.fixedThreadPool[A](config.awaitConnectionThreads) // our connect EC
xa <- HikariTransactor.fromHikariConfig[A](hikariConfig, ec)
// ec <- ExecutionContexts.fixedThreadPool[A](config.awaitConnectionThreads) // our connect EC
xa <- HikariTransactor.fromHikariConfig[A](hikariConfig, Some(LogHandler.jdkLogHandler))
} yield xa

pool.toManaged.toLayer[Transactor[A]]
Expand Down

0 comments on commit fa9daff

Please sign in to comment.