Compare commits

...

9 commits

5 changed files with 63 additions and 22 deletions

View file

@ -36,6 +36,10 @@ release:
stage: deploy stage: deploy
script: script:
- ncc build --config release --log-level debug - ncc build --config release --log-level debug
- >
curl --header "JOB-TOKEN: $CI_JOB_TOKEN"
--upload-file build/release/net.nosial.focuscrawler.ncc
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/net.nosial.tamerlib/$CI_COMMIT_TAG/net.nosial.tamerlib.ncc"
artifacts: artifacts:
paths: paths:
- build/ - build/

View file

@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.1.5] - 2023-07-06
### Fixed
- `\TamerLib\tm > wait()` will output worker updates even if there are no jobs in the queue, this fixes a bug where
workers would not be updated if the client only calls `dof()`
## [2.1.4] - 2023-07-28
### Fixed
- `\TamerLib\Classes > JobManager > connect()` re-constructs the Redis client before connecting to the server.
## [2.1.3] - 2023-07-27
### Changed
- `\TamerLib\Classes > JobManager > disconnect()` now disconnects even if the server is still connected, this is to
prevent the server from being left in a bad state if the connection is lost.
## [2.1.2] - 2023-07-09
### Changed
- `\TamerLib\tm > wait()` no longer throws a TimeoutException, the function will simply return when the timeout is
reached.
## [2.1.1] - 2023-07-07 ## [2.1.1] - 2023-07-07
### Fixed ### Fixed
@ -13,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
being dropped. being dropped.
## [2.1.0] - 2023-07-07 ## [2.1.0] - 2023-07-07
### Added ### Added
@ -44,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
queue while the callback was running. queue while the callback was running.
## [2.0.1] - 2023-06-30 ## [2.0.1] - 2023-06-30
Minor bugfixes and improvements. Minor bugfixes and improvements.
@ -56,6 +89,7 @@ Minor bugfixes and improvements.
handled by the client and just be discarded. handled by the client and just be discarded.
## [2.0.0] - 2023-06-18 ## [2.0.0] - 2023-06-18
This version of TamerLib offers a comprehensive framework for implementing parallel processing in PHP applications. This version of TamerLib offers a comprehensive framework for implementing parallel processing in PHP applications.
@ -81,12 +115,15 @@ versions.
- Workers can now throw exceptions which are caught and re-thrown on the client side. - Workers can now throw exceptions which are caught and re-thrown on the client side.
This allows for robust error handling across different parts of the application. This allows for robust error handling across different parts of the application.
## [1.0.1] - 2022-02-28 ## [1.0.1] - 2022-02-28
### Added ### Added
- Added more logging calls for Gearman Client - Added more logging calls for Gearman Client
## [1.0.0] - 2022-02-09 ## [1.0.0] - 2022-02-09
### Added ### Added

View file

@ -22,7 +22,7 @@
"description": "TamerLib allows the execution of parallel tasks", "description": "TamerLib allows the execution of parallel tasks",
"company": "Nosial", "company": "Nosial",
"copyright": "Copyright (c) 2022-2023 Nosial, All Rights Reserved", "copyright": "Copyright (c) 2022-2023 Nosial, All Rights Reserved",
"version": "2.1.1", "version": "2.1.5",
"uuid": "a365e7d6-a1c0-11ed-b7c7-b9654ed9efa5" "uuid": "a365e7d6-a1c0-11ed-b7c7-b9654ed9efa5"
}, },
"build": { "build": {

View file

@ -110,6 +110,8 @@
try try
{ {
$this->redis_client = new Redis();
$this->redis_client->connect( $this->redis_client->connect(
$this->server_configuration->getHost(), $this->server_configuration->getHost(),
$this->server_configuration->getPort() $this->server_configuration->getPort()
@ -141,17 +143,15 @@
*/ */
public function disconnect(): void public function disconnect(): void
{ {
if($this->isConnected())
{
return;
}
Log::debug(Utilities::getName(), sprintf('JobManager disconnecting from %s:%s', $this->server_configuration->getHost(), $this->server_configuration->getPort())); Log::debug(Utilities::getName(), sprintf('JobManager disconnecting from %s:%s', $this->server_configuration->getHost(), $this->server_configuration->getPort()));
try try
{
if($this->redis_client instanceof Redis)
{ {
$this->redis_client->close(); $this->redis_client->close();
} }
}
catch(Exception $e) catch(Exception $e)
{ {
Log::warning(Utilities::getName(),sprintf('JobManager could not disconnect safely from %s:%s', $this->server_configuration->getHost(), $this->server_configuration->getPort()), $e); Log::warning(Utilities::getName(),sprintf('JobManager could not disconnect safely from %s:%s', $this->server_configuration->getHost(), $this->server_configuration->getPort()), $e);

View file

@ -456,7 +456,6 @@
* @throws JobManagerException If the JobManager throws an exception * @throws JobManagerException If the JobManager throws an exception
* @throws TamerException If the Tamer throws an exception * @throws TamerException If the Tamer throws an exception
* @throws Throwable If a job fails * @throws Throwable If a job fails
* @throws TimeoutException If the timeout is reached
*/ */
public static function wait(int $timeout=0): void public static function wait(int $timeout=0): void
{ {
@ -465,25 +464,27 @@
throw new RuntimeException(sprintf('Attempting to wait() in \'%s\' mode, only clients can preform wait().', self::$mode)); throw new RuntimeException(sprintf('Attempting to wait() in \'%s\' mode, only clients can preform wait().', self::$mode));
} }
$time_start = time(); self::monitor(-1);
if(count(self::$watching_jobs) === 0) if(count(self::$watching_jobs) === 0)
{ {
return; return;
} }
$time_start = time();
$watching_jobs = self::$watching_jobs; $watching_jobs = self::$watching_jobs;
Log::verbose(Utilities::getName(), sprintf('Waiting for %s job(s) to complete', count($watching_jobs))); Log::verbose(Utilities::getName(), sprintf('Waiting for %s job(s) to complete', count($watching_jobs)));
while(true) while(true)
{ {
self::monitor(-1);
if(count($watching_jobs) === 0) if(count($watching_jobs) === 0)
{ {
return; return;
} }
self::monitor(-1);
$job_id = self::$job_manager->listenReturnChannel(self::$return_channel); $job_id = self::$job_manager->listenReturnChannel(self::$return_channel);
if(!in_array($job_id, $watching_jobs, false)) if(!in_array($job_id, $watching_jobs, false))
{ {
Log::debug(Utilities::getName(), sprintf('Job \'%s\' has returned, but is not in the watchlist', $job_id)); Log::debug(Utilities::getName(), sprintf('Job \'%s\' has returned, but is not in the watchlist', $job_id));
@ -492,7 +493,6 @@
} }
$job_packet = self::$job_manager->getJob($job_id); $job_packet = self::$job_manager->getJob($job_id);
if(isset(self::$job_callbacks[$job_id])) if(isset(self::$job_callbacks[$job_id]))
{ {
$callback = self::$job_callbacks[$job_id]; $callback = self::$job_callbacks[$job_id];
@ -548,12 +548,12 @@
if ($timeout < 0) if ($timeout < 0)
{ {
throw new TimeoutException('wait() timed out'); return;
} }
if($timeout > 0 && (time() - $time_start) >= $timeout) if($timeout > 0 && (time() - $time_start) >= $timeout)
{ {
throw new TimeoutException('wait() timed out'); return;
} }
usleep(1000); usleep(1000);