Skip to content

Commit

Permalink
PJAS-466 Refactor annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
dgjorgjiev-prospective committed May 29, 2024
1 parent 19504f8 commit 6430679
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 155 deletions.
7 changes: 0 additions & 7 deletions phpstan.neon

This file was deleted.

52 changes: 31 additions & 21 deletions src/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Beryllium\Driver;

use Beryllium\Job;
use Generator;

interface DriverInterface
{
Expand All @@ -16,23 +15,26 @@ interface DriverInterface
/**
* Adds the given Job to the queue
*
* @param Job $job
* @param int $maxRetries
* @param Job $job
* @param int $maxRetries
*
* @return void
*/
public function add(Job $job, int $maxRetries = 3) : void;

/**
* Get a job instance by the given id.
*
* @param string $id The Job identifier.
* @param string $id The Job identifier.
*
* @return Job
*/
public function get(string $id) : ?Job;

/**
* Check if a job exists in the queue
* @param string $id
*
* @param string $id The Job identifier.
*
* @return bool
*/
Expand All @@ -55,31 +57,35 @@ public function waitingCount() : int;
/**
* Reinsert the job into the waitlist
*
* @param string $id The Job identifier.
* @param string $id The Job identifier.
*
* @return void
*/
public function retry(string $id) : void;

/**
* Get the maximum number of attempts we should try for the job
*
* @param string $id The Job identifier.
* @return int Returns -1 if the job has never been executed
* @param string $id The Job identifier.
*
* @return int Returns -1 if the job has never been executed
*/
public function getMaxRetries(string $id) : int;

/**
* Get the number of attempts this job already had.
*
* @param string $id The Job identifier.
* @return int Returns -1 if the job has never been executed
* @param string $id The Job identifier.
*
* @return int Returns -1 if the job has never been executed
*/
public function attemptCount(string $id) : int;

/**
* Cleanup the jobs data
*
* @param string $id The Job identifier.
* @param string $id The Job identifier.
*
* @return void
*/
public function cleanup(string $id) : void;
Expand All @@ -101,16 +107,18 @@ public function clearEverything() : void;
/**
* Simply store a value
*
* @param string $key
* @param mixed $value
* @param string $key
* @param mixed $value
*
* @return void
*/
public function storeStatsValue(string $key, $value) : void;

/**
* Simply get a value
*
* @param string $key
* @param string $key
*
* @return mixed
*/
public function getStatsValue(string $key);
Expand All @@ -124,25 +132,27 @@ public function getStatsValue(string $key);
/**
* Checks if the given key is locked on the driver.
*
* @param string $key
* @param string $key
*
* @return bool
*/
public function isLocked(string $key) : bool;

/**
* Returns the locks token
*
* @param string $key
* @param string $key
*
* @return string
*/
public function getLockToken(string $key) : ?string;

/**
* Creates a lock entry on the driver, this must be synchronised!
*
* @param string $key
* @param string $token
* @param int $ttl
* @param string $key
* @param string $token
* @param int $ttl
*
* @return bool Returns true if the lock could be created
*/
Expand All @@ -152,8 +162,8 @@ public function lock(string $key, string $token, int $ttl) : bool;
* Removes a lock entry on the driver, this must be synchronised!
* Also the lock for the key should only be removed if the token matches!
*
* @param string $key
* @param string $token
* @param string $key
* @param string $token
*
* @return bool Retruns true if the lock could be removed.
*/
Expand Down
52 changes: 31 additions & 21 deletions src/Driver/PHPArrayDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Beryllium\Driver;

use Beryllium\Job;
use Generator;

class PHPArrayDriver implements DriverInterface
{
Expand Down Expand Up @@ -42,8 +41,9 @@ class PHPArrayDriver implements DriverInterface
/**
* Adds the given Job to the queue
*
* @param Job $job
* @param int $maxRetries
* @param Job $job
* @param int $maxRetries
*
* @return void
*/
public function add(Job $job, int $maxRetries = 3) : void
Expand All @@ -57,7 +57,8 @@ public function add(Job $job, int $maxRetries = 3) : void
/**
* Get a job instance by the given id.
*
* @param string $id The Job identifier.
* @param string $id The Job identifier.
*
* @return Job
*/
public function get(string $id) : ?Job
Expand All @@ -67,7 +68,8 @@ public function get(string $id) : ?Job

/**
* Check if a job exists in the queue
* @param string $id
*
* @param string $id The Job identifier.
*
* @return bool
*/
Expand Down Expand Up @@ -99,7 +101,8 @@ public function waitingCount() : int
/**
* Reinsert the job into the waitlist
*
* @param string $id The Job identifier.
* @param string $id The Job identifier.
*
* @return void
*/
public function retry(string $id) : void
Expand All @@ -111,8 +114,9 @@ public function retry(string $id) : void
/**
* Get the maximum number of attempts we should try for the job
*
* @param string $id The Job identifier.
* @return int Returns -1 if the job has never been executed
* @param string $id The Job identifier.
*
* @return int Returns -1 if the job has never been executed
*/
public function getMaxRetries(string $id) : int
{
Expand All @@ -122,8 +126,9 @@ public function getMaxRetries(string $id) : int
/**
* Get the number of attempts this job already had.
*
* @param string $id The Job identifier.
* @return int Returns -1 if the job has never been executed
* @param string $id The Job identifier.
*
* @return int Returns -1 if the job has never been executed
*/
public function attemptCount(string $id) : int
{
Expand All @@ -133,7 +138,8 @@ public function attemptCount(string $id) : int
/**
* Cleanup the jobs data
*
* @param string $id The Job identifier.
* @param string $id The Job identifier.
*
* @return void
*/
public function cleanup(string $id) : void
Expand Down Expand Up @@ -162,8 +168,9 @@ public function clearEverything() : void
/**
* Simply store a value
*
* @param string $key
* @param mixed $value
* @param string $key
* @param mixed $value
*
* @return void
*/
public function storeStatsValue(string $key, $value) : void
Expand All @@ -174,7 +181,8 @@ public function storeStatsValue(string $key, $value) : void
/**
* Simply get a value
*
* @param string $key
* @param string $key
*
* @return mixed
*/
public function getStatsValue(string $key)
Expand All @@ -185,7 +193,8 @@ public function getStatsValue(string $key)
/**
* Checks if the given key is locked on the driver.
*
* @param string $key
* @param string $key
*
* @return bool
*/
public function isLocked(string $key) : bool
Expand All @@ -196,7 +205,8 @@ public function isLocked(string $key) : bool
/**
* Returns the locks token
*
* @param string $key
* @param string $key
*
* @return string
*/
public function getLockToken(string $key) : ?string
Expand All @@ -207,9 +217,9 @@ public function getLockToken(string $key) : ?string
/**
* Creates a lock entry on the driver, this must be synchronised!
*
* @param string $key
* @param string $token
* @param int $ttl
* @param string $key
* @param string $token
* @param int $ttl
*
* @return bool Returns true if the lock could be created
*/
Expand All @@ -227,8 +237,8 @@ public function lock(string $key, string $token, int $ttl) : bool
* Removes a lock entry on the driver, this must be synchronised!
* Also the lock for the key should only be removed if the token matches!
*
* @param string $key
* @param string $token
* @param string $key
* @param string $token
*
* @return bool Retruns true if the lock could be removed.
*/
Expand Down
Loading

0 comments on commit 6430679

Please sign in to comment.