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 | $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.
Connect to Redis and start subscribing.
Disconnect from Redis.
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.
Attempt to reconnect to Redis.
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 45
__construct(PubSubIncomingMessageHandler $messageHandler, RedisProxy $redis, string $channel)
Create a new Redis pub/sub provider instance.
at line 58
void
connect()
Connect to Redis and start subscribing.
Uses the injected Redis connection's subscriber() factory so the dedicated subscriber inherits its topology, credentials, and prefix.
at line 101
void
disconnect()
Disconnect from Redis.
at line 112
protected void
consumeMessages(Subscriber $subscriber, string $subscribedChannel)
Process messages from one committed subscriber.
at line 151
void
on(string $event, callable $callback)
Listen for a given event type.
at line 159
void
listen(string $event, callable $callback)
Listen for the given event.
at line 167
void
stopListening(string $event)
Stop listening for the given event.
at line 175
int
publish(array $payload)
Publish a payload to the Redis channel.
at line 183
protected void
reconnect()
Attempt to reconnect to Redis.
at line 216
protected bool
shouldRetry()
Determine whether reconnect work remains enabled.
Hooked Redis I/O and Sleep may yield while disconnect() changes this state.
at line 224
protected void
clearSubscriber(Subscriber|null $subscriber)
Clear committed state only when it still belongs to the given subscriber.
at line 237
protected void
closeSubscriber(Subscriber|null $subscriber)
Close an owned subscriber without replacing the primary lifecycle failure.