My this piece of code complaining about type mismatch; found: Unit required: scala.concurrent.Future
, whereas I am returning a Future
. I am very new in Scala not sure what I am missing here .
val records: List[CommittableRecord[Either[Throwable, MyEvent]]] = ???
records.mapAsync(1){ x =>
val res = (x.value match {
case Right(event:MyEvent) =>
val future = getTask(event.get("task").getOrElse(""))
//future => Future[Try[Int]]
val k = future.map {
case Success(value) => value
case Failure(exception) => 0
}
//k => Future[Int]
})
}
Variable assignment returns Unit
, just remove val k =
or put k
at the end