[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer) | `<3.42.1` -> `<3.43.2` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary> ### [`v3.43.1`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3431) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.43.0...v3.43.1) - fix: Import only unique symbols' short names ([#​7635](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7635)) ### [`v3.43.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3430) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.42.0...v3.43.0) - chore: change base of `@Symfony` set to `@PER-CS2.0` ([#​7627](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7627)) - chore: PHPUnit - allow for v10 ([#​7606](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7606)) - chore: Preg - rework catching the error ([#​7616](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7616)) - chore: Revert unneeded peer-dep-pin and re-gen lock file ([#​7618](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7618)) - docs: drop extra note about 8.0.0 bug in README.md ([#​7614](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7614)) - feat: add cast_spaces into `@PER-CS2.0` ([#​7625](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7625)) - feat: Configurable phpDoc tags for FQCN processing ([#​7628](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7628)) - feat: StatementIndentationFixer - introduce stick_comment_to_next_continuous_control_statement config ([#​7624](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7624)) - feat: UnaryOperatorSpacesFixer - introduce only_dec_inc config ([#​7626](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7626)) - fix: FullyQualifiedStrictTypesFixer - better support annotations in inline {} ([#​7633](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7633)) - fix: Improve how FQCN is handled in phpDoc ([#​7622](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7622)) - fix: phpdoc_align - fix multiline tag alignment issue ([#​7630](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7630)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/libretime/libretime). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo <ljonas@riseup.net>
118 lines
3.8 KiB
PHP
118 lines
3.8 KiB
PHP
<?php
|
|
|
|
abstract class Application_Service_ThirdPartyCeleryService extends Application_Service_ThirdPartyService
|
|
{
|
|
/**
|
|
* @var string broker exchange name for third-party tasks
|
|
*/
|
|
protected static $_CELERY_EXCHANGE_NAME;
|
|
|
|
/**
|
|
* @var array map of celery identifiers to their task names
|
|
*/
|
|
protected static $_CELERY_TASKS;
|
|
|
|
/**
|
|
* Execute a Celery task with the given name and data parameters.
|
|
*
|
|
* @param string $taskName the name of the celery task to execute
|
|
* @param array $data the data array to send as task parameters
|
|
* @param int $fileId the unique identifier for the file involved in the task
|
|
*
|
|
* @return CeleryTasks the created task
|
|
*
|
|
* @throws Exception
|
|
*/
|
|
protected function _executeTask($taskName, $data, $fileId = null)
|
|
{
|
|
try {
|
|
$brokerTaskId = CeleryManager::sendCeleryMessage(
|
|
$taskName,
|
|
static::$_CELERY_EXCHANGE_NAME,
|
|
$data
|
|
);
|
|
|
|
return $this->_createTaskReference($fileId, $brokerTaskId, $taskName);
|
|
} catch (Exception $e) {
|
|
Logging::error('Invalid request: ' . $e->getMessage());
|
|
|
|
throw $e;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create a CeleryTasks object for a pending task
|
|
* TODO: should we have a database layer class to handle Propel operations?
|
|
*
|
|
* @param $fileId int CcFiles identifier
|
|
* @param $brokerTaskId int broker task identifier to so we can asynchronously
|
|
* receive completed task messages
|
|
* @param $taskName string broker task name
|
|
*
|
|
* @return CeleryTasks the created task
|
|
*
|
|
* @throws Exception
|
|
* @throws PropelException
|
|
*/
|
|
protected function _createTaskReference($fileId, $brokerTaskId, $taskName)
|
|
{
|
|
$trackReferenceId = $this->createTrackReference($fileId);
|
|
$task = new CeleryTasks();
|
|
$task->setDbTaskId($brokerTaskId);
|
|
$task->setDbName($taskName);
|
|
$utc = new DateTimeZone('UTC');
|
|
$task->setDbDispatchTime(new DateTime('now', $utc));
|
|
$task->setDbStatus(CELERY_PENDING_STATUS);
|
|
$task->setDbTrackReference($trackReferenceId);
|
|
$task->save();
|
|
|
|
return $task;
|
|
}
|
|
|
|
/**
|
|
* Update a CeleryTasks object for a completed task
|
|
* TODO: should we have a database layer class to handle Propel operations?
|
|
*
|
|
* @param $task CeleryTasks the completed CeleryTasks object
|
|
* @param $status string Celery task status
|
|
*
|
|
* @throws Exception
|
|
* @throws PropelException
|
|
*/
|
|
public function updateTask($task, $status)
|
|
{
|
|
$task->setDbStatus($status);
|
|
$task->save();
|
|
}
|
|
|
|
/**
|
|
* Update a ThirdPartyTrackReferences object for a completed upload.
|
|
*
|
|
* Manipulation and use of the track object is left up to child implementations
|
|
*
|
|
* @param $task CeleryTasks the completed CeleryTasks object
|
|
* @param $trackId int ThirdPartyTrackReferences identifier
|
|
* @param $result mixed Celery task result message
|
|
* @param $status string Celery task status
|
|
*
|
|
* @return ThirdPartyTrackReferences the updated ThirdPartyTrackReferences object
|
|
*
|
|
* @throws Exception
|
|
* @throws PropelException
|
|
*/
|
|
public function updateTrackReference($task, $trackId, $result, $status)
|
|
{
|
|
static::updateTask($task, $status);
|
|
$ref = ThirdPartyTrackReferencesQuery::create()
|
|
->findOneByDbId($trackId);
|
|
if (is_null($ref)) {
|
|
$ref = new ThirdPartyTrackReferences();
|
|
}
|
|
$ref->setDbService(static::$_SERVICE_NAME);
|
|
$utc = new DateTimeZone('UTC');
|
|
$ref->setDbUploadTime(new DateTime('now', $utc));
|
|
$ref->save();
|
|
|
|
return $ref;
|
|
}
|
|
}
|