akka/akka-core

Source.actorRefWithAck for batch sending to stream

オープン

#26,818 opened on 2019/04/26

 (0 件のコメント) (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)

説明

https://github.com/akka/akka/pull/26633 added actorRefWithAck with 1-1 acks and no buffering (single element buffer).

We could also have a variant with a buffer and OverflowStrategy similar to ActorRefSource and SourceQueue.

Then we could also support batch sending into the stream by having having a function that evaluates if an ack should be sent back for a given element and thereby 1-1 acks are not needed. Could be ackMessage: Any => Option[Any], where the first Any is the incoming message and the second is optionally the ack message.

Then one can define a Source.actorRefWithAck with buffer size 100 and use it like:

ackMessage = n => if (n % 50 == 0) Some(n) else None

ref ! 1
ref ! 2
ref ! 3
...
ref ! 99
// wait for ack 50 if not already received
ref ! 100
ref ! 101
...
ref ! 149
// wait for ack 100 if not already received
...

Inspiration for jmh benchmark can be found in https://github.com/akka/akka/blob/master/akka-bench-jmh/src/main/scala/akka/remote/artery/SendQueueBenchmark.scala#L79

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