akka/akka-core

Add an optional buffer/parallelism parameter for actorRefWithAck

オープン

#26,129 opened on 2018/12/17

 (6 件のコメント) (0 件のリアクション) (0 人の担当者)Scala (3,547 件のフォーク)batch import
1 - triagedhelp wantedt:stream

Repository metrics

Stars
 (13,277 個のスター)
PR merge metrics
 (平均マージ 8d 19h) (30d で 10 merged PRs)

説明

Flow.ask currently takes in a parallelism factor as an optional parameter. This allows messages to buffer in the destination ActorRef's mailbox. E.g.,

def myFlow(ref: ActorRef) = {
  Source(1 to 100)
    .ask[Response](4)(ref) //allows 4 messages to send before waiting for a Response
    .to(Sink.ignore)
}

Sink.actorRefWithAck does not have any such functionality. Messages do not buffer.

def myAckFlow(ref: ActorRef) = {
  Source(1 to 100)
    //waits for a Response before sending the next element
    .runWith(Sink.actorRefWithAck(ref,Init,Response,Completed, ex => Error(ex))
}

Johan and I discussed this briefly, and he felt like it would be a reasonable thing to add a parallelism (or buffer) parameter to actorRefWithAck.

コントリビューターガイド