I would like to pass on incoming file upload as separate chunks down a GenStage, but I would like some expert advice/confirmation on my thinking. I also would like to know of anything Elixir might handle differently.
When reading the binary chunks from the Plug connection, I want to create a tuple per chunk. The binary chunk is one of the message tuple fields. When a message is sent from one process to another, the message is copied and then linked into the mailbox of the target process according this and this page.
The documentation on Erlang binaries mention that the real binary data is handled off-heap, with a
ProcBin wrapper on-heap.
So, if I create a tuple message containing a binary, am I right that only the tuple with the ProcBin wrapper is copied into the target mailbox and the real binary data is not?