phasync
Subscription / getIterator

Method

Subscription::getIterator

The messages, as they come; null after each $heartbeat seconds without one.

Description#

public Subscription::getIterator(): Generator

Throws a WorkerStoppingException when the worker stops. A subscription made while draining ends at once.

Return values#

Each message as published (a JSON message decoded; an object as a SealedObject), or null for a heartbeat Generator

Errors / Exceptions#

ExceptionWhen
SubscriberLagExceptionWhen the next message arrived more than $maxLag seconds ago

Examples#

Example 1
foreach (Swerve::subscribe('chat') as $message) {
    handle($message);
}