Skip to main content

Goal

Stream a large or binary payload from one function to another without putting the data itself in a JSON function payload. Use a normal function invocation when the payload is small JSON and can be handled as one request. Use a channel when the payload is large, binary, or naturally stream-shaped. Good fits for channels:
  • File uploads and downloads.
  • Images, audio, video, PDFs, and datasets.
  • Progress updates during long-running work.
  • Producer and consumer pipelines where the data should move as a stream.
For the underlying model, see Channels architecture.

Steps

1. Create a channel

A channel has two local stream objects and two serializable refs:
  • writer: local writable stream.
  • reader: local readable stream.
  • writerRef: serializable token for the writer end.
  • readerRef: serializable token for the reader end.

2. Write to the channel

Write the stream payload to the local writer and close it when you are done.

3. Pass the reader ref to another function

Pass the readerRef / reader_ref as part of a normal function invocation. The receiving function uses that ref to read from the channel.

4. Read from the channel

Node and Python deserialize channel refs into live channel objects before your handler runs. Rust receives the ref in JSON and reconstructs the reader with ChannelReader::new(...).

Result

The caller passes only a small ref through trigger(). The stream payload travels over the channel, and the receiving function reads it incrementally.