RedisPubSubProvider
class RedisPubSubProvider implements PubSubProvider
Properties
| protected Subscriber|null | $subscriber | The Redis subscriber instance. |
|
| protected string | $subscribedChannel | The actual Redis channel name (with prefix applied). |
|
| protected bool | $running | Whether the subscriber lifecycle coroutine is running. |
|
| protected bool | $shouldRetry | Whether the provider should attempt to reconnect. |
|
| protected int | $retryTimer | The number of seconds elapsed since attempting to reconnect. |
Methods
Create a new Redis pub/sub provider instance.
Start the Redis subscriber lifecycle.
Disconnect from Redis.
Own subscriber construction, consumption, cleanup, and retry.
Process messages from one committed subscriber.
Listen for a given event type.
Listen for the given event.
Stop listening for the given event.
Publish a payload to the Redis channel.
Report a connection failure without flooding logs during an outage.
Wait before attempting another connection.
Determine whether reconnect work remains enabled.
Clear committed state only when it still belongs to the given subscriber.
Close an owned subscriber without replacing the primary lifecycle failure.
Details
at line 52
__construct(PubSubIncomingMessageHandler $messageHandler, RedisProxy $redis, string $channel)
Create a new Redis pub/sub provider instance.
at line 65
void
connect()
Start the Redis subscriber lifecycle.
Uses the injected Redis connection's subscriber() factory so the dedicated subscriber inherits its topology, credentials, and prefix.
at line 98
void
disconnect()
Disconnect from Redis.
at line 109
protected void
runSubscriberLifecycle()
Own subscriber construction, consumption, cleanup, and retry.
at line 146
protected void
consumeMessages(Subscriber $subscriber, string $subscribedChannel)
Process messages from one committed subscriber.
at line 172
void
on(string $event, callable $callback)
Listen for a given event type.
at line 180
void
listen(string $event, callable $callback)
Listen for the given event.
at line 188
void
stopListening(string $event)
Stop listening for the given event.
at line 196
int
publish(array $payload)
Publish a payload to the Redis channel.
at line 204
protected void
reportConnectionFailure(Throwable $exception)
Report a connection failure without flooding logs during an outage.
at line 216
protected bool
waitBeforeRetry()
Wait before attempting another connection.
at line 229
protected bool
shouldRetry()
Determine whether reconnect work remains enabled.
Hooked Redis I/O and coordinator waits may yield while disconnect() changes this state.
at line 237
protected void
clearSubscriber(Subscriber|null $subscriber)
Clear committed state only when it still belongs to the given subscriber.
at line 250
protected void
closeSubscriber(Subscriber|null $subscriber)
Close an owned subscriber without replacing the primary lifecycle failure.