akka/akka-core
View on GitHubAdd an optional buffer/parallelism parameter for actorRefWithAck
Open
#26,129 opened on Dec 17, 2018
1 - triagedhelp wantedt:stream
Repository metrics
- Stars
- (13,277 stars)
- PR merge metrics
- (Avg merge 8d 19h) (10 merged PRs in 30d)
Description
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.