I am wondering about the 10, the bufferSize value. Is there a simple way to monitor the usage of that buffer? Also, is it possible build this Source another way, such that it inherits its bufferSize from some Akka application.conf default value?
For the config question:
You can create a function which creates a source with the configured bufferd size for ex: function [type] mySource() { return Source.<AkkaOutbound>actorRef(config.DEFAULT_BUFFER_SIZE, OverflowStrategy.fail());} but if I remember well there is no builtin default for that value.
For the monitoring question:
Most of the time coming up with a good buffer size is either trialByError or already known from the scope. You can measure some parts of the flow with tools, but the buffer and paralelism numbers normally depends on the hardware, and the actual usecase: what are the loads, how much user you have, how much memory you have, etc.
On the monitoring point, I appreciate the pointer to Akka Stream Checkpoint, but it seems to be Scala only? Also was hoping for just a simple way to be able to log the current usage of the buffer, a current used number, so as to reach the knowledge on what would be a reasonable number.
Yapp, as I know: all of the lightbend stuff uses this type of config: https://github.com/lightbend/config
The link seems to be correct, create your application.conf file, write some staff in it, and you can use as the documentation describes.
The checkpoint will work with java too. (Most of the stream stuff written in scala so the documentation and examples are mainly in scala, sometimes the java interface written in scala too, but it doesn’t matter, if it defines the java-dsl too.) You can’t monitor the buffer inner state easily. If you don’t want to touch scala code I don’t even think you can hack into to do it.
If I would like to know the number of elements inside a Source.actorRef’s buffer, I would copy the source actor, extend it with status request messages, and copy + rewrite the factory function and the actual source too. Not so elegant, but after you have your very own implementation you can do whatever you want with it.
I open an issue with your problem, see what the owners think of the idea, and if they like it I will PR it for you, but that could be month…