MAKS\AmqpAgent\Worker\AbstractWorker
An abstract class implementing the basic functionality of a worker.
Synopsis
- // members
- protected $connectionOptions;
- protected $channelOptions;
- protected $queueOptions;
- public AMQPStreamConnection $connection;
- public AMQPChannel $channel;
- public array $connections = ;
- public array $channels = ;
- // methods
- public void __construct()
- public void __destruct()
- public mixed __get()
- public void __set()
- public static bool shutdown()
- public static AMQPTable arguments()
- public AbstractWorker connect()
- public AbstractWorker disconnect()
- public AbstractWorker reconnect()
- public AbstractWorker queue()
- public ?AMQPStreamConnection getConnection()
- public AbstractWorker setConnection()
- public AMQPStreamConnection getNewConnection()
- public ?AMQPChannel getChannel()
- public AbstractWorker setChannel()
- public ?AMQPChannel getNewChannel()
- public ?AMQPChannel getChannelById()
- // Inherited methods from MagicMethodsExceptionsTrait
- public void __get()
- public void __set()
- public mixed __call()
- public static mixed __callStatic()
- // Inherited methods from WorkerMutationTrait
- protected array mutateClassMember()
- protected array mutateClassSubMember()
- // Inherited methods from WorkerCommandTrait
- public static array makeCommand()
- public static bool isCommand()
- public static bool hasCommand()
- public static mixed getCommand()
Hierarchy
Uses
- MAKS\AmqpAgent\Exception\MagicMethodsExceptionsTrait
- MAKS\AmqpAgent\Worker\WorkerMutationTrait
- MAKS\AmqpAgent\Worker\WorkerCommandTrait
Implements
Coverage
Methods | 88.24% | 15 / 17 |
Lines | 98.39% | 122 / 124 |
Members
protected
- $channelOptions
—
array
The default channel options that the worker should use when no overrides are provided. - $connectionOptions
—
array
The default connection options that the worker should use when no overrides are provided. - $mutation
—
array
The last mutation happened to a class member (for debugging purposes). - $queueOptions
—
array
The default queue options that the worker should use when no overrides are provided.
public
- $channel
—
PhpAmqpLib\Channel\AMQPChannel
The default channel of the worker. - $channels
—
array
All opened channels of the the worker. - $commandPrefix
—
string
The prefix that should be used to define an array as a command. - $commandSyntax
—
array
The recommended way of defining a command array. - $connection
—
PhpAmqpLib\Connection\AMQPStreamConnection
The default connection of the worker. - $connections
—
array
All opened connections of the worker.
Methods
public
- __construct() — AbstractWorker object constructor.
- __destruct() — Closes the connection with RabbitMQ server before destroying the object.
- __get() — Gets a class member via public property access notation.
- __set() — Sets a class member via public property assignment notation.
- arguments() — Returns an AMQPTable object.
- connect() — Establishes a connection with RabbitMQ server and opens a channel for the worker in the opened connection, it also sets both of them as defaults.
- disconnect() — Closes all open channels and connections with RabbitMQ server.
- getChannel() — Returns the default channel of the worker. If the worker is not connected, it returns null.
- getChannelById() — Fetches a channel object identified by the passed id (channel_id). If not found, it returns null.
- getConnection() — Returns the default connection of the worker. If the worker is not connected, it returns null.
- getNewChannel() — Returns a new channel on the the passed connection of the worker. If no connection is passed, it uses the default connection. If the worker is not connected, it returns null.
- getNewConnection() — Opens a new connection to RabbitMQ server and returns it. Connections returned by this method pushed to connections array and are not set as default automatically.
- queue() — Declares a queue on the default channel of the worker's connection with RabbitMQ server.
- reconnect() — Executes `self::disconnect()` and `self::connect()` respectively. Note that this method will not restore old channels.
- setChannel() — Sets the passed channel as the default channel of the worker.
- setConnection() — Sets the passed connection as the default connection of the worker.
- shutdown() — Closes the connection or the channel or both with RabbitMQ server.
Inherited from MAKS\AmqpAgent\Exception\MagicMethodsExceptionsTrait
public
- __call() — Throws an exception for calls to undefined methods.
- __callStatic() — Throws an exception for calls to undefined static methods.
- __get() — Throws an exception when trying to get a class member via public property assignment notation.
- __set() — Throws an exception when trying to set a class member via public property assignment notation.
Inherited from MAKS\AmqpAgent\Worker\WorkerMutationTrait
protected
- mutateClassMember() — Mutates a subset of an array (class property) and returns the replaced subset.
- mutateClassSubMember() — Mutates a subset of an array inside a class property (nested array inside a property) and returns the replaced subset.
Inherited from MAKS\AmqpAgent\Worker\WorkerCommandTrait
public
- getCommand() — Returns the content of a specific key in the command array, used for example to get the additional parameters.
- hasCommand() — Checks whether a specific command (command name) exists in the command array.
- isCommand() — Checks whether an array is a command following the recommended pattern.
- makeCommand() — Constructs a command from passed data to a command array following the recommended pattern.
History
-
2021-01-12T21:10:22+00:00 (commit #e758246)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update abstract worker class * Remove return value type hint "self" from methods signature due to unexpected behavior with different PHP versions
-
2021-01-12T21:10:22+00:00 (commit #1b19c14)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update abstract worker class * Refactor useless code * Change exception type of shutdown() method * Fix typos * Update DocBlocks
-
2021-01-12T21:10:21+00:00 (commit #447b1ed)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update abstract worker class * Fix some coding style issues
-
2021-01-12T21:10:21+00:00 (commit #d09424b)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Add strict types declaration * Add declare(strict_types=1) to all files * Fix file header DocBlock spacing of all files
-
2020-09-25T20:15:48+00:00 (commit #56955bb)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Refactor abstract worker class * Make use of the newly created AbstractWorkerParameters class * Make use of the newly created MagicMethodsExceptionsTrait * Update the class in different places to make use of the new additions
-
2020-09-23T19:26:04+00:00 (commit #cd6ed4f)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Remove PHPUnit annotations * Remove @codeCoverageIgnore annotations from the workers
-
2020-09-23T18:47:06+00:00 (commit #1a3f203)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Fix typos and update DocBlocks * Fix some typos in DockBlocks and other parts of the codebase * Add examples to classes DocBlocks
-
2020-09-13T23:00:41+00:00 (commit #0044405)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Fix php-amqplib v2.12.0 deprecations * Fix references to deprecated properties in php-amqplib v2.12.0
-
2020-09-13T22:03:14+00:00 (commit #936f31a)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update abstract worker class * Change arguments method to a static method * Update method signature corresponding interface * Update method references on workers singleton classes (DocBlocks)
-
2020-08-09T22:12:03+00:00 (commit #fd2c6b8)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Update AbstractWorker class * Add connections array and channels array. * Add setConnection(), getNewConnection() and setChannel() methods. * Modify old methods to make use of the newly created methods internally. * Update the methods signature on the corresponding interface (AbstractWorkerInterface)
-
2020-06-13T05:50:47+00:00 (commit #afcd511)
Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com)
Implement the abstract worker * Add AbstractWorker.php * Add WorkerMutationTrait.php * Add WorkerCommandTrait.php