• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

input-output-hk / atala-prism-building-blocks / 5487952008

07 Jul 2023 03:17PM UTC coverage: 28.258% (+0.2%) from 28.076%
5487952008

Pull #575

bvoiturier
Merge branch 'main' into feature/ATL-4093-simple-event-mechanism
Pull Request #575: feat(prism-agent): simple event mechanism using webhook

384 of 384 new or added lines in 15 files covered. (100.0%)

2747 of 9721 relevant lines covered (28.26%)

0.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

59.46
/connect/lib/core/src/main/scala/io/iohk/atala/connect/core/service/ConnectionServiceNotifier.scala
1
package io.iohk.atala.connect.core.service
2

3
import io.iohk.atala.connect.core.model.ConnectionRecord
4
import io.iohk.atala.connect.core.model.error.ConnectionServiceError
5
import io.iohk.atala.event.notification.{Event, EventNotificationService}
6
import io.iohk.atala.mercury.model.DidId
7
import io.iohk.atala.mercury.protocol.connection.{ConnectionRequest, ConnectionResponse}
8
import zio.{IO, URLayer, ZIO, ZLayer}
9

10
import java.util.UUID
11

12
class ConnectionServiceNotifier(
13
    svc: ConnectionService,
14
    eventNotificationService: EventNotificationService
15
) extends ConnectionService {
16

1✔
17
  override def createConnectionInvitation(
18
      label: Option[String],
19
      pairwiseDID: DidId
20
  ): IO[ConnectionServiceError, ConnectionRecord] =
1✔
21
    notifyOnSuccess(svc.createConnectionInvitation(label, pairwiseDID))
22

1✔
23
  override def receiveConnectionInvitation(invitation: String): IO[ConnectionServiceError, ConnectionRecord] =
1✔
24
    notifyOnSuccess(svc.receiveConnectionInvitation(invitation))
25

1✔
26
  override def acceptConnectionInvitation(
27
      recordId: UUID,
28
      pairwiseDid: DidId
29
  ): IO[ConnectionServiceError, ConnectionRecord] =
1✔
30
    notifyOnSuccess(svc.acceptConnectionInvitation(recordId, pairwiseDid))
31

1✔
32
  override def markConnectionRequestSent(recordId: UUID): IO[ConnectionServiceError, ConnectionRecord] =
1✔
33
    notifyOnSuccess(svc.markConnectionRequestSent(recordId))
34

1✔
35
  override def receiveConnectionRequest(request: ConnectionRequest): IO[ConnectionServiceError, ConnectionRecord] =
1✔
36
    notifyOnSuccess(svc.receiveConnectionRequest(request))
37

1✔
38
  override def acceptConnectionRequest(recordId: UUID): IO[ConnectionServiceError, ConnectionRecord] =
1✔
39
    notifyOnSuccess(svc.acceptConnectionRequest(recordId))
40

1✔
41
  override def markConnectionResponseSent(recordId: UUID): IO[ConnectionServiceError, ConnectionRecord] =
1✔
42
    notifyOnSuccess(svc.markConnectionResponseSent(recordId))
43

1✔
44
  override def receiveConnectionResponse(response: ConnectionResponse): IO[ConnectionServiceError, ConnectionRecord] =
1✔
45
    notifyOnSuccess(svc.receiveConnectionResponse(response))
46

1✔
47
  private[this] def notifyOnSuccess(effect: IO[ConnectionServiceError, ConnectionRecord]) =
1✔
48
    for {
49
      record <- effect
1✔
50
      _ <- notify(record)
51
    } yield record
52

1✔
53
  private[this] def notify(record: ConnectionRecord) = {
1✔
54
    val result = for {
×
55
      producer <- eventNotificationService.producer[ConnectionRecord]("Connect")
×
56
      _ <- producer.send(Event(record))
57
    } yield ()
×
58
    result.catchAll(e => ZIO.logError(s"Notification service error: $e"))
59
  }
60

×
61
  override def getConnectionRecord(recordId: UUID): IO[ConnectionServiceError, Option[ConnectionRecord]] =
×
62
    svc.getConnectionRecord(recordId)
63

×
64
  override def getConnectionRecordByThreadId(thid: String): IO[ConnectionServiceError, Option[ConnectionRecord]] =
×
65
    svc.getConnectionRecordByThreadId(thid)
66

×
67
  override def deleteConnectionRecord(recordId: UUID): IO[ConnectionServiceError, Int] =
×
68
    svc.deleteConnectionRecord(recordId)
69

×
70
  override def reportProcessingFailure(recordId: UUID, failReason: Option[String]): IO[ConnectionServiceError, Unit] =
×
71
    svc.reportProcessingFailure(recordId, failReason)
72

×
73
  override def getConnectionRecords(): IO[ConnectionServiceError, Seq[ConnectionRecord]] =
×
74
    svc.getConnectionRecords()
75

×
76
  override def getConnectionRecordsByStates(
77
      ignoreWithZeroRetries: Boolean,
78
      limit: Int,
79
      states: ConnectionRecord.ProtocolState*
80
  ): IO[ConnectionServiceError, Seq[ConnectionRecord]] =
×
81
    svc.getConnectionRecordsByStates(ignoreWithZeroRetries, limit, states: _*)
82
}
83

84
object ConnectionServiceNotifier {
85
  val layer: URLayer[ConnectionService & EventNotificationService, ConnectionService] =
1✔
86
    ZLayer.fromFunction(ConnectionServiceNotifier(_, _))
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc