控制未到达Scala嵌套映射中的特定位置

时间:2017-11-30 13:49:30

标签: scala akka akka-persistence

def startProcessing() = {
   readQuery
  .eventsByTag(TaggingEventAdapter.driverStateEvent, Offset.noOffset)
  .groupedWithin(5, 2.seconds)
  .mapAsync(1) { envelopes =>
    processEvents(envelopes.map(_.event)).map(_ => envelopes.last.offset).map{
      offset => self ! UpdateOffsetCommand(TaggingEventAdapter.driverStateEvent, offset)
    }
  }
  .runWith(Sink.ignore)
}

def processEvents(events: Seq[Any]): Future[Unit] = {
log.info(events.toString())
null
} 

当我的代码控制没有到达时 map{offset => self ! UpdateOffsetCommand(TaggingEventAdapter.TestStateEvent, offset)}位置,

鉴于eventsByTag在向量中获得两个事件。 envelopes也是事件。但它没有达到第三map

1 个答案:

答案 0 :(得分:1)

您的processEvents方法看起来非常可疑,因为它返回null。将其更改为以下内容(假设log.info的返回类型为Unit):

def processEvents(events: Seq[Any]): Future[Unit] = Future {
  log.info(events.toString())
}