Final remarks

Despite being an impressive tool, GenStage, and its cousin Flow, are not silver bullets. By using these abstractions, one incurs some expense due to the initial setup. Remember that, under the hood, processes are being spawned and messages are being exchanged and potentially buffered. As such, consider whether you really need to apply GenStage or whether you simply want a multistep pipeline that processes events, without the need for a back-pressure mechanism. If it's parallel processing you're after, maybe the Task.async_stream/1 we already talked about can do the job.

You can check the :message_queue_len entry of the Process.info/1 result to know how many messages a process currently has in its mailbox. The following snippet ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.