From a873090fdd2560eb78263060d502946f142b0574 Mon Sep 17 00:00:00 2001 From: patlo-iog <108713642+patlo-iog@users.noreply.github.com> Date: Wed, 9 Nov 2022 18:28:24 +0700 Subject: [PATCH] fix(prism-agent): reuse db connection for background job (#102) --- .../scala/io/iohk/atala/agent/server/Modules.scala | 11 +++++------ .../io/iohk/atala/agent/server/http/HttpRoutes.scala | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Modules.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Modules.scala index 2b48a7cf6e..a577cc851f 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Modules.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/Modules.scala @@ -77,17 +77,17 @@ object Modules { val didCommServiceEndpoint: Task[Nothing] = { val app: HttpApp[Any, Nothing] = Http.collect[Request] { case Method.POST -> !! / "did-comm-v2" => - // TODO add DIDComm messages parsing logic here! + // TODO add DIDComm messages parsing logic here! Response.text("Hello World!").setStatus(Status.Accepted) } Server.start(8090, app) } - val didCommExchangesJob: Task[Unit] = { - val effect = BackgroundJobs.didCommExchanges + val didCommExchangesJob: Task[Unit] = + BackgroundJobs.didCommExchanges + .repeat(Schedule.spaced(10.seconds)) + .unit .provideLayer(AppModule.credentialServiceLayer) - (effect repeat Schedule.spaced(10.seconds)).unit - } } @@ -191,7 +191,6 @@ object HttpModule { } val layers = - didApiLayer ++ didOperationsApiLayer ++ didAuthenticationApiLayer ++ didRegistrarApiLayer ++ issueCredentialsApiLayer ++ issueCredentialsProtocolApiLayer } diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/HttpRoutes.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/HttpRoutes.scala index 70a40736d6..aae9e27a3d 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/HttpRoutes.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/http/HttpRoutes.scala @@ -16,7 +16,8 @@ import akka.http.scaladsl.server.Route object HttpRoutes { def routes: URIO[ - DIDApi & DIDOperationsApi & DIDAuthenticationApi & DIDRegistrarApi & IssueCredentialsApi & IssueCredentialsProtocolApi, + DIDApi & DIDOperationsApi & DIDAuthenticationApi & DIDRegistrarApi & IssueCredentialsApi & + IssueCredentialsProtocolApi, Route ] = for {