Skip to content

Commit

Permalink
feat(prism-agent): Upgrade libs (#344)
Browse files Browse the repository at this point in the history
Upgrade connect to 0.8.0
Upgrade pollux to 0.22.0
Upgrade mercury to 0.17.0
Fix code
  • Loading branch information
FabioPinheiro authored Feb 7, 2023
1 parent 19b3c49 commit 64a7857
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 12 deletions.
6 changes: 3 additions & 3 deletions prism-agent/service/project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ object Dependencies {
val akka = "2.6.20"
val akkaHttp = "10.2.9"
val castor = "0.8.0"
val pollux = "0.22.0"
val connect = "0.7.0"
val pollux = "0.23.0"
val connect = "0.9.0"
val bouncyCastle = "1.70"
val logback = "1.4.5"
val mercury = "0.16.0"
val mercury = "0.17.0"
val zioJson = "0.3.0"
val tapir = "1.2.3"
val flyway = "9.8.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ object Modules {
for {
_ <- ZIO.logInfo("*" * 100)
_ <- ZIO.logInfo("As an Inviter in connect:")
connectionRequest = ConnectionRequest.readFromMessage(msg)
connectionRequest <- ConnectionRequest.fromMessage(msg) match {
case Left(error) => ZIO.fail(new RuntimeException(error))
case Right(value) => ZIO.succeed(value)
}
_ <- ZIO.logInfo("Got ConnectionRequest: " + connectionRequest)
// Receive and store ConnectionRequest
maybeRecord <- connectionService
Expand All @@ -360,7 +363,10 @@ object Modules {
for {
_ <- ZIO.logInfo("*" * 100)
_ <- ZIO.logInfo("As an Invitee in connect:")
connectionResponse = ConnectionResponse.readFromMessage(msg)
connectionResponse <- ConnectionResponse.fromMessage(msg) match {
case Left(error) => ZIO.fail(new RuntimeException(error))
case Right(value) => ZIO.succeed(value)
}
_ <- ZIO.logInfo("Got ConnectionResponse: " + connectionResponse)
_ <- connectionService
.receiveConnectionResponse(connectionResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ class IssueCredentialsProtocolApiServiceImpl(
ProtocolState.ConnectionResponseSent,
_,
_,
Some(resp)
Some(resp),
_, // metaRetries: Int,
_, // metaLastFailure: Option[String]
) =>
ZIO.succeed(DidIdPair(resp.from, resp.to))
case ConnectionRecord(
Expand All @@ -186,7 +188,9 @@ class IssueCredentialsProtocolApiServiceImpl(
ProtocolState.ConnectionResponseReceived,
_,
_,
Some(resp)
Some(resp),
_, // metaRetries: Int,
_, // metaLastFailure: Option[String]
) =>
ZIO.succeed(DidIdPair(resp.to, resp.from))
case _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,9 @@ object BackgroundJobs {

private[this] def performPublishCredentialsToDlt(credentialService: CredentialService) = {
val res: ZIO[Any, CredentialServiceError, Unit] = for {
records <- credentialService.getCredentialRecordsByState(IssueCredentialRecord.ProtocolState.CredentialPending)
records <- credentialService.getIssueCredentialRecordsByStates(
IssueCredentialRecord.ProtocolState.CredentialPending
)
// NOTE: the line below is a potentially slow operation, because <createCredentialPayloadFromRecord> makes a database SELECT call,
// so calling this function n times will make n database SELECT calls, while it can be optimized to get
// all data in one query, this function here has to be refactored as well. Consider doing this if this job is too slow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,64 @@ object ConnectBackgroundJobs {
import Role._
import ProtocolState._
val exchange = record match {
case ConnectionRecord(id, _, _, _, _, Invitee, ConnectionRequestPending, _, Some(request), _) =>
for {
case ConnectionRecord(
id,
_,
_,
_,
_,
Invitee,
ConnectionRequestPending,
_,
Some(request),
_,
metaRetries,
_
) if metaRetries > 0 =>
val aux = for {

didCommAgent <- buildDIDCommAgent(request.from)
_ <- MessagingService.send(request.makeMessage).provideSomeLayer(didCommAgent)
connectionService <- ZIO.service[ConnectionService]
_ <- connectionService.markConnectionRequestSent(id)
} yield ()

case ConnectionRecord(id, _, _, _, _, Inviter, ConnectionResponsePending, _, _, Some(response)) =>
for {
// aux // TODO decrete metaRetries if it has a error
aux

case ConnectionRecord(
id,
_,
_,
_,
_,
Inviter,
ConnectionResponsePending,
_,
_,
Some(response),
metaRetries,
_
) if metaRetries > 0 =>
val aux = for {
didCommAgent <- buildDIDCommAgent(response.from)
_ <- MessagingService.send(response.makeMessage).provideSomeLayer(didCommAgent)
connectionService <- ZIO.service[ConnectionService]
_ <- connectionService.markConnectionResponseSent(id)
} yield ()

aux.tapError(ex =>
for {
connectionService <- ZIO.service[ConnectionService]
_ <- connectionService
.reportProcessingFailure(id, None) // TODO ex get message
} yield ()
)
case e
if (e.protocolState == ConnectionRequestPending || e.protocolState == ConnectionResponsePending) && e.metaRetries == 0 =>
ZIO.logWarning( // TODO use logDebug
s"ConnectionRecord '${e.id}' has '${e.metaRetries}' retries and will NOT be processed"
)
case _ => ZIO.unit
}

Expand Down

0 comments on commit 64a7857

Please sign in to comment.