PhoenixGenApi.Structs.StreamHelper (PhoenixGenApi v2.17.1)

Copy Markdown View Source

Helper struct and functions for sending streaming data to a StreamCall process.

A %StreamHelper{} holds the PID of the stream process and the request ID. Use the provided functions to send data chunks, completion signals, and errors to the stream process, which forwards them to the client as {:stream_response, response} messages.

Usage

stream = %StreamHelper{stream_pid: pid, request_id: "req_123"}
StreamHelper.send_result(stream, chunk_data)       # intermediate chunk
StreamHelper.send_last_result(stream, final_data)   # final chunk
StreamHelper.send_complete(stream)                   # normal completion
StreamHelper.send_error(stream, reason)              # error

Summary

Types

t()

Stream helper struct.

Functions

Wrap complete & send to stream.

Wrap error & send to stream.

Wrap last result & send to stream.

Wrap result & send to stream.

Types

t()

@type t() :: %PhoenixGenApi.Structs.StreamHelper{
  request_id: String.t(),
  stream_pid: pid()
}

Stream helper struct.

Functions

send_complete(stream)

Wrap complete & send to stream.

send_error(stream, error)

Wrap error & send to stream.

send_last_result(stream, result)

Wrap last result & send to stream.

send_result(stream, result)

Wrap result & send to stream.