FileAccess Orion

Consumer extends AbstractConsumer
in package

PUB/SUB consumer abstraction.

Tags
author

Daniele Alessandri suppakilla@gmail.com

Table of Contents

MESSAGE  = 'message'
PMESSAGE  = 'pmessage'
PONG  = 'pong'
PSUBSCRIBE  = 'psubscribe'
PUNSUBSCRIBE  = 'punsubscribe'
STATUS_PSUBSCRIBED  = 4
STATUS_SUBSCRIBED  = 2
STATUS_VALID  = 1
SUBSCRIBE  = 'subscribe'
UNSUBSCRIBE  = 'unsubscribe'
$client  : mixed
$options  : mixed
$position  : mixed
$statusFlags  : mixed
__construct()  : mixed
__destruct()  : mixed
Automatically stops the consumer when the garbage collector kicks in.
current()  : array<string|int, mixed>
Returns the last message payload retrieved from the server and generated by one of the active subscriptions.
getClient()  : ClientInterface
Returns the underlying client instance used by the pub/sub iterator.
key()  : mixed
{@inheritdoc}
next()  : mixed
{@inheritdoc}
ping()  : mixed
PING the server with an optional payload that will be echoed as a PONG message in the pub/sub loop.
psubscribe()  : mixed
Subscribes to the specified channels using a pattern.
punsubscribe()  : mixed
Unsubscribes from the specified channels using a pattern.
rewind()  : mixed
{@inheritdoc}
stop()  : bool
Closes the context by unsubscribing from all the subscribed channels. The context can be forcefully closed by dropping the underlying connection.
subscribe()  : mixed
Subscribes to the specified channels.
unsubscribe()  : mixed
Unsubscribes from the specified channels.
valid()  : bool
Checks if the the consumer is still in a valid state to continue.
disconnect()  : mixed
Closes the underlying connection when forcing a disconnection.
getValue()  : array<string|int, mixed>
Waits for a new message from the server generated by one of the active subscriptions and returns it when available.
invalidate()  : mixed
Resets the state of the consumer.
isFlagSet()  : bool
Checks if the specified flag is valid based on the state of the consumer.
writeRequest()  : mixed
Writes a Redis command on the underlying connection.
checkCapabilities()  : mixed
Checks if the client instance satisfies the required conditions needed to initialize a PUB/SUB consumer.
genericSubscribeInit()  : mixed
This method shares the logic to handle both SUBSCRIBE and PSUBSCRIBE.

Constants

Properties

Methods

__construct()

public __construct(ClientInterface $client[, array<string|int, mixed> $options = null ]) : mixed
Parameters
$client : ClientInterface

Client instance used by the consumer.

$options : array<string|int, mixed> = null

Options for the consumer initialization.

Return values
mixed

__destruct()

Automatically stops the consumer when the garbage collector kicks in.

public __destruct() : mixed
Return values
mixed

current()

Returns the last message payload retrieved from the server and generated by one of the active subscriptions.

public current() : array<string|int, mixed>
Return values
array<string|int, mixed>

ping()

PING the server with an optional payload that will be echoed as a PONG message in the pub/sub loop.

public ping([string $payload = null ]) : mixed
Parameters
$payload : string = null

Optional PING payload.

Return values
mixed

psubscribe()

Subscribes to the specified channels using a pattern.

public psubscribe(mixed $pattern) : mixed
Parameters
$pattern : mixed
Return values
mixed

punsubscribe()

Unsubscribes from the specified channels using a pattern.

public punsubscribe() : mixed
Return values
mixed

stop()

Closes the context by unsubscribing from all the subscribed channels. The context can be forcefully closed by dropping the underlying connection.

public stop([bool $drop = false ]) : bool
Parameters
$drop : bool = false

Indicates if the context should be closed by dropping the connection.

Return values
bool

Returns false when there are no pending messages.

subscribe()

Subscribes to the specified channels.

public subscribe(mixed $channel) : mixed
Parameters
$channel : mixed
Return values
mixed

unsubscribe()

Unsubscribes from the specified channels.

public unsubscribe() : mixed
Return values
mixed

valid()

Checks if the the consumer is still in a valid state to continue.

public valid() : bool
Return values
bool

disconnect()

Closes the underlying connection when forcing a disconnection.

protected disconnect() : mixed
Return values
mixed

getValue()

Waits for a new message from the server generated by one of the active subscriptions and returns it when available.

protected getValue() : array<string|int, mixed>
Return values
array<string|int, mixed>

invalidate()

Resets the state of the consumer.

protected invalidate() : mixed
Return values
mixed

isFlagSet()

Checks if the specified flag is valid based on the state of the consumer.

protected isFlagSet(int $value) : bool
Parameters
$value : int

Flag.

Return values
bool

writeRequest()

Writes a Redis command on the underlying connection.

protected writeRequest(mixed $method, mixed $arguments) : mixed
Parameters
$method : mixed

Command ID.

$arguments : mixed

Arguments for the command.

Return values
mixed

checkCapabilities()

Checks if the client instance satisfies the required conditions needed to initialize a PUB/SUB consumer.

private checkCapabilities(ClientInterface $client) : mixed
Parameters
$client : ClientInterface

Client instance used by the consumer.

Tags
throws
NotSupportedException
Return values
mixed

genericSubscribeInit()

This method shares the logic to handle both SUBSCRIBE and PSUBSCRIBE.

private genericSubscribeInit(string $subscribeAction) : mixed
Parameters
$subscribeAction : string

Type of subscription.

Return values
mixed

Search results