Implemented RabbitMQ and Refactored Client & Worker (WIP)

This commit is contained in:
Netkas 2023-02-02 21:09:45 -05:00
parent d15da30813
commit 6d8d4a75a4
13 changed files with 966 additions and 170 deletions

View file

@ -2,17 +2,18 @@
namespace Tamer\Interfaces;
use Closure;
use Tamer\Objects\Task;
interface ClientProtocolInterface
{
/**
* Adds options to the client (client specific)
* Public Constructor with optional username and password
*
* @param array $options
* @return bool
* @param string|null $username (optional) The username to use when connecting to the server (if required)
* @param string|null $password (optional) The password to use when connecting to the server
*/
public function addOptions(array $options): bool;
public function __construct(?string $username=null, ?string $password=null);
/**
* Adds a server to the list of servers to use
@ -32,27 +33,12 @@
public function addServers(array $servers): bool;
/**
* Processes a task in the background (does not return a result)
*
* @param Task $task The task to process
* @return void
*/
public function doBackground(Task $task): void;
/**
* Queues a task to be processed in parallel (returns a result handled by a callback)
*
* @param Task $task
* @return void
*/
public function addTask(Task $task): void;
/**
* Executes all tasks in the queue and waits for them to complete
* Adds options to the client (client specific)
*
* @param array $options
* @return bool
*/
public function run(): bool;
public function addOptions(array $options): bool;
/**
* Returns True if the client is set to automatically reconnect to the server after a period of time
@ -68,4 +54,44 @@
* @return void
*/
public function setAutomaticReconnect(bool $automatic_reconnect): void;
/**
* Processes a task in the background (does not return a result)
*
* @param Task $task The task to process
* @return void
*/
public function do(Task $task): void;
/**
* Executes a closure operation in the background (does not return a result)
*
* @param Closure $closure The closure operation to perform (remote)
* @return void
*/
public function doClosure(Closure $closure): void;
/**
* Queues a task to be processed in parallel (returns a result handled by a callback)
*
* @param Task $task
* @return void
*/
public function queue(Task $task): void;
/**
* Queues a closure to be processed in parallel (returns a result handled by a callback)
*
* @param Closure $closure The closure operation to perform (remote)
* @param Closure $callback The closure to call when the operation is complete (local)
* @return void
*/
public function queueClosure(Closure $closure, Closure $callback): void;
/**
* Executes all tasks in the queue and waits for them to complete
*
* @return bool
*/
public function run(): bool;
}