| Methods |
public
|
__construct(
Closure(): SupervisableTransportInterface $factory,
int $maxRestarts = 3,
float $restartDelay = 0.1,
LoggerInterface $logger = new NullLogger(),
float $restartWindow = self::DEFAULT_RESTART_WINDOW,
null|(Closure(): float) $clock = null,
)
Parameters
| $factory |
Mints one connection, called once per spawn.
|
| $maxRestarts |
Respawns allowed within one window before giving up.
|
| $restartDelay |
Seconds to wait before each respawn.
|
| $restartWindow |
Seconds the restart count is measured over.
|
| $clock |
Reads the current time in seconds, replaceable so the window boundary is exact under test. A source in other units silently makes the budget unspendable.
|
|
#
|
public
|
start(): void
Begins consuming inbound envelopes from the peer. Returns immediately.
Begins consuming inbound envelopes from the peer. Returns immediately.
Implements
|
#
|
public
|
send(JsonRpcMessage $message, ?SendContext $context = null): void
Enqueues an outbound JSON-RPC message to the peer. On write failure, close listeners fire before the exception is rethrown.
Enqueues an outbound JSON-RPC message to the peer. On write failure, close listeners fire before the exception is rethrown.
Implements
|
#
|
public
|
close(): void
Closes the connection. The onClose() listener fires once after the
underlying streams are closed. Subsequent calls are no-ops. Implementations MUST guarantee that onClose() listeners fire after a
fatal error too, not only after explicit close(). Server::run()
blocks on the close signal, so a transport that raises errors without
eventually closing would hang the server loop.
Closes the connection. The onClose() listener fires once after the
underlying streams are closed. Subsequent calls are no-ops. Implementations MUST guarantee that onClose() listeners fire after a
fatal error too, not only after explicit close(). Server::run()
blocks on the close signal, so a transport that raises errors without
eventually closing would hang the server loop.
Implements
|
#
|
public
|
onMessage(Closure $listener): SubscriptionInterface
Register an inbound-envelope listener.
Register an inbound-envelope listener.
Implements
|
#
|
public
|
onError(Closure $listener): SubscriptionInterface
Register an error listener.
Register an error listener.
Implements
|
#
|
public
|
onDrain(Closure $listener): SubscriptionInterface
Register a drain listener that fires before close().
Register a drain listener that fires before close().
Implements
|
#
|
public
|
onClose(Closure $listener): SubscriptionInterface
Register a close listener.
Register a close listener.
Implements
|
#
|
public
|
isReconnecting(): bool
Whether a replacement connection is still on its way. False on a live connection and false once the
transport has stopped for good, whether it was closed or gave up. Answers "will what just failed be tried again?", so it is read when a per-connection operation fails,
not before one is issued.
Whether a replacement connection is still on its way. False on a live connection and false once the
transport has stopped for good, whether it was closed or gave up. Answers "will what just failed be tried again?", so it is read when a per-connection operation fails,
not before one is issued.
Implements
|
#
|
public
|
onReconnect(Closure $listener): SubscriptionInterface
Registers a listener invoked once for every replacement connection that has started serving.
It runs after the close emitted for the connection being replaced, and never for the first
connection, which start() already reports. A protocol layer holding per-connection state uses this to rebuild it. The fresh peer has no
memory of the old one, so anything the caller expects to survive must be re-sent.
Registers a listener invoked once for every replacement connection that has started serving.
It runs after the close emitted for the connection being replaced, and never for the first
connection, which start() already reports. A protocol layer holding per-connection state uses this to rebuild it. The fresh peer has no
memory of the old one, so anything the caller expects to survive must be re-sent.
Implements
|
#
|