Skip to content

Commit

Permalink
fix(mediator) : escala_to configurable (#108)
Browse files Browse the repository at this point in the history
* Problem report escalato confgurable and renamed type

Signed-off-by: Shailesh Patil <[email protected]>

* Problem report escalato confgurable and renamed type

Signed-off-by: Shailesh Patil <[email protected]>

* Problem report escalato confgurable and renamed type

Signed-off-by: Shailesh Patil <[email protected]>

* removed the hello endpoint

Signed-off-by: Shailesh Patil <[email protected]>

---------

Signed-off-by: Shailesh Patil <[email protected]>
  • Loading branch information
mineme0110 authored Sep 4, 2023
1 parent aa19f0a commit d1f0ac4
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions mediator/src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ mediator = {
dbName = "mediator"
dbName = ${?MONGODB_DB_NAME}
}
problem.report.escalateTo = "[email protected]"
problem.report.escalateTo = ${?ESCALATE_TO}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import io.iohk.atala.mediator.protocols.MissingProtocolExecuter

trait ProtocolExecuter[-R, +E] { // <: MediatorError | StorageError] {

def suportedPIURI: Seq[PIURI]
def supportedPIURI: Seq[PIURI]

/** @return can return a Sync Reply Msg */
def execute[R1 <: R](
Expand All @@ -37,9 +37,9 @@ case class ProtocolExecuterCollection[-R <: Agent, +E](
executers: ProtocolExecuter[R, E]*
) extends ProtocolExecuter[R, E] {

override def suportedPIURI: Seq[PIURI] = executers.flatMap(_.suportedPIURI)
override def supportedPIURI: Seq[PIURI] = executers.flatMap(_.supportedPIURI)

def selectExecutersFor(piuri: PIURI) = executers.find(_.suportedPIURI.contains(piuri))
def selectExecutersFor(piuri: PIURI) = executers.find(_.supportedPIURI.contains(piuri))

override def execute[R1 <: R](
plaintextMessage: PlaintextMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ object MediatorStandalone extends ZIOAppDefault {
Request,
Response
] = MediatorAgent.didCommApp
++ Http
.collectZIO[Request] { case Method.GET -> Root / "hello" =>
ZIO.succeed(Response.text("Hello World! DID Comm Mediator APP")).debug
}
override val run = for {
_ <- Console.printLine( // https://patorjk.com/software/taag/#p=display&f=ANSI%20Shadow&t=Mediator
"""███╗ ███╗███████╗██████╗ ██╗ █████╗ ████████╗ ██████╗ ██████╗
Expand All @@ -98,6 +94,12 @@ object MediatorStandalone extends ZIOAppDefault {
.nested("mediator")
.load(Config.int("port"))
_ <- ZIO.log(s"Starting server on port: $port")
escalateTo <- configs
.nested("report")
.nested("problem")
.nested("mediator")
.load(Config.string("escalateTo"))
_ <- ZIO.log(s"Problem reports escalated to : $escalateTo")
client = Scope.default >>> Client.default
inboundHub <- Hub.bounded[String](5)
myServer <- Server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import zio.{Console, ZIO}

object BasicMessageExecuter extends ProtocolExecuter[Any, MediatorError] {

override def suportedPIURI: Seq[PIURI] = Seq(BasicMessage.piuri)
override def supportedPIURI: Seq[PIURI] = Seq(BasicMessage.piuri)
override def program[R1 <: Any](plaintextMessage: PlaintextMessage) = for {
job <- BasicMessage.fromPlaintextMessage(plaintextMessage) match
case Left(error) => ZIO.fail(MediatorDidError(FailToParse(error)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object ForwardMessageExecuter
ProtocolExecuter.Erros
] {

override def suportedPIURI: Seq[PIURI] = Seq(ForwardMessage.piuri)
override def supportedPIURI: Seq[PIURI] = Seq(ForwardMessage.piuri)

override def program[R1 <: UserAccountRepo & MessageItemRepo & Agent](
plaintextMessage: PlaintextMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object MediatorCoordinationExecuter
ProtocolExecuter.Erros
] {

override def suportedPIURI: Seq[PIURI] = Seq(
override def supportedPIURI: Seq[PIURI] = Seq(
MediateRequest.piuri,
MediateGrant.piuri,
MediateDeny.piuri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import io.iohk.atala.mediator.actions.Reply

object MissingProtocolExecuter extends ProtocolExecuter[Agent, Nothing] {

override def suportedPIURI = Seq()
override def supportedPIURI = Seq()
override def program[R1 <: Agent](plaintextMessage: PlaintextMessage) =
ZIO
.service[Agent]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import zio.ZIO

object NullProtocolExecuter extends ProtocolExecuter[Any, MissingProtocolError] {

override def suportedPIURI = Seq()
override def supportedPIURI = Seq()
override def program[R1 <: Any](plaintextMessage: PlaintextMessage) =
ZIO.fail(MissingProtocolError(plaintextMessage.`type`))
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object PickupExecuter
ProtocolExecuter.Erros
] {

override def suportedPIURI: Seq[PIURI] = Seq(
override def supportedPIURI: Seq[PIURI] = Seq(
StatusRequest.piuri,
Status.piuri,
DeliveryRequest.piuri,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.iohk.atala.mediator.protocols

import com.typesafe.config.{Config, ConfigFactory}
import fmgp.did.*
import fmgp.did.comm.*
import fmgp.did.comm.protocol.reportproblem2.*

object Problems {
val email = Some("[email protected]")
val config: Config = ConfigFactory.load()
val email: Option[String] = Option(config.getString("mediator.problem.report.escalateTo"))

def unsupportedProtocolType(
to: Set[TO],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import zio.ZIO

class TrustPingExecuter extends ProtocolExecuterWithServices[ProtocolExecuter.Services, MediatorError] {

override def suportedPIURI: Seq[PIURI] = Seq(TrustPing.piuri, TrustPingResponse.piuri)
override def supportedPIURI: Seq[PIURI] = Seq(TrustPing.piuri, TrustPingResponse.piuri)

override def program[R1 <: Agent](
plaintextMessage: PlaintextMessage
Expand Down

0 comments on commit d1f0ac4

Please sign in to comment.