Skip to content

Commit

Permalink
Don't JSON encode the work ID sent by the merger
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwlchan committed Oct 19, 2020
1 parent 12ebde0 commit d4ecba6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Expand Up @@ -48,13 +48,20 @@ class MergerWorkerService[WorkDestination, ImageDestination](
case Right(works) => Future.successful(works)
}
(worksFuture, imagesFuture) = (
sendMessages(workSender, works.map(_.id)),
sendWorks(works),
sendMessages(imageSender, mergerOutcome.images)
)
_ <- worksFuture
_ <- imagesFuture
} yield ()

private def sendWorks(works: Seq[Work[Merged]]): Future[Seq[Unit]] =
Future.sequence(
works.map { w =>
Future.fromTry(workSender.send(w.id))
}
)

private def sendMessages[Destination, T](
sender: MessageSender[Destination],
items: Seq[T])(implicit encoder: Encoder[T]): Future[Seq[Unit]] =
Expand Down
Expand Up @@ -57,7 +57,7 @@ trait WorkerServiceFixture extends LocalWorksVhs with SQS with Akka {
}

def getWorksSent(workSender: MemoryMessageSender): Seq[String] =
workSender.getMessages[String]
workSender.messages.map { _.body }

def getImagesSent(imageSender: MemoryMessageSender): Seq[MergedImage[DataState.Unidentified]] =
imageSender.getMessages[MergedImage[DataState.Unidentified]]
Expand Down

0 comments on commit d4ecba6

Please sign in to comment.