createChannel()
Create a bidirectional channel for streaming data between workers.number
default:"64"
Optional buffer size for the channel
Channel
Channel object with writer and reader
Example: Basic Channel Usage
ChannelWriter
Write data to a channel for streaming to another function.Properties
Writable
Node.js Writable stream for sending data
Methods
sendMessage()
Send a text message through the channel.string
required
Text message to send
close()
Close the channel writer.Example: Writing Data
ChannelReader
Read data from a channel streamed by another function.Properties
Readable
Node.js Readable stream for receiving data
Methods
onMessage()
Register a callback for text messages.(msg: string) => void
required
Function called for each text message received
Example: Reading Data
Complete Examples
File Processing Pipeline
Large Dataset Transfer
Best Practices
Always close writers
Always close writers
Handle backpressure
Handle backpressure
Process chunks incrementally
Process chunks incrementally
Use appropriate buffer sizes
Use appropriate buffer sizes
Handle errors properly
Handle errors properly
StreamChannelRef
Channel references can be serialized and passed to other functions.ChannelReader or ChannelWriter instances when received by function handlers.