Skip to content

RoadRunnerResponseEmitter

Hands the response back to RoadRunner over the worker relay.

An ordinary response goes through PSR7Worker::respond(), which serialises the whole body into one payload. A streaming body instead goes to HttpWorker::respond() with a Generator, which RoadRunner sends as a sequence of frames — one per yielded chunk, so an SSE event reaches the client as soon as the action produces it rather than when the stream finally ends.

The generator is driven off SseStream::read() rather than PSR7Worker’s own chunkSize property, which is marked @internal.

final class RoadRunnerResponseEmitter implements ResponseEmitterInterface

ImplementsResponseEmitterInterface
SourceRoadRunnerResponseEmitter.php
ConstantValueDescription
DEFAULT_CHUNK_SIZE8192

public function __construct(PSR7Worker $worker, int $chunkSize = self::DEFAULT_CHUNK_SIZE): mixed

ParameterTypeDescription
$workerPSR7Worker
$chunkSizeint

Returns mixed

MethodDescription
emit(ResponseInterface $response): voidSends the response back over the RoadRunner relay.
supportsStreaming(): boolAlways true: RoadRunner sends a generator body as a sequence of frames.

public function emit(ResponseInterface $response): void

Sends the response back over the RoadRunner relay.

An ordinary body goes out in a single payload via PSR7Worker::respond(). An SseStream body is instead handed to the underlying HTTP worker as a generator, so each chunk leaves as its own frame while the action is still producing events.

ParameterTypeDescription
$responseResponseInterface

public function supportsStreaming(): bool

Always true: RoadRunner sends a generator body as a sequence of frames.

Returns bool