Method
OrderedChannel::subscribe
Receive what is written from now on, as Swerve::subscribe does.
Description#
public OrderedChannel::subscribe(
float $maxLag = 30.0,
?float $heartbeat = null
): SubscriptionThe subscription exists once this returns.
Parameters#
- $maxLag float = 30.0
- Seconds a message may wait before this subscriber reads it
- $heartbeat ?float = null
- Seconds without a message after which the loop yields null; null for never
Return values#
Subscription
Errors / Exceptions#
| Exception | When |
|---|---|
InvalidArgumentException | For a name of 0 or over 255 bytes, or starting with "\0" |
LogicException | Directly in swerve.php, which the worker serves after: a coroutine started there waits instead |
Examples#
$subscription = (new OrderedChannel('ledger'))->subscribe(maxLag: 10.0);
foreach ($subscription as $entry) { ... }See also#
OrderedChannel::writeAppend$messageto the channel, where every subscriber receives it in the channel's one order.