-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
3,002 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ matrix: | |
env: COVERAGE=yes | ||
- php: 7.3 | ||
include: | ||
- php: 5.6 | ||
- php: 7.1 | ||
- php: 7.2 | ||
- php: 7.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2016 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
/** */ | ||
namespace Core\Log\Processor; | ||
|
||
use Zend\Log\Processor\ProcessorInterface; | ||
|
||
/** | ||
* Adds the process id to the event array in the key 'pid'. | ||
* | ||
* @author Mathias Gelhausen <gelhausen@cross-solution.de> | ||
*/ | ||
class ProcessId implements ProcessorInterface | ||
{ | ||
/** | ||
* Adds process id to the event array. | ||
* | ||
* @param array $event | ||
* | ||
* @return array | ||
*/ | ||
public function process(array $event) | ||
{ | ||
$event['pid'] = getmypid(); | ||
|
||
return $event; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2019 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
/** */ | ||
namespace Core\Queue\Controller; | ||
|
||
use SlmQueue\Controller\AbstractWorkerController; | ||
|
||
/** | ||
* Console Controller for mongo queues | ||
* | ||
* @author Mathias Gelhausen <gelhausen@cross-solution.de> | ||
*/ | ||
class MongoQueueController extends AbstractWorkerController | ||
{ | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
module/Core/src/Queue/Controller/MongoQueueControllerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2019 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
/** */ | ||
namespace Core\Queue\Controller; | ||
|
||
use Core\Queue\Worker\MongoWorker; | ||
use Interop\Container\ContainerInterface; | ||
use SlmQueue\Queue\QueuePluginManager; | ||
use Zend\ServiceManager\Factory\FactoryInterface; | ||
|
||
/** | ||
* Factory for \Core\Queue\Controller\MongoQueueController | ||
* | ||
* @author Mathias Gelhausen <gelhausen@cross-solution.de> | ||
*/ | ||
class MongoQueueControllerFactory implements FactoryInterface | ||
{ | ||
|
||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) | ||
{ | ||
$service = new MongoQueueController( | ||
$container->get(MongoWorker::class), | ||
$container->get(QueuePluginManager::class) | ||
); | ||
|
||
return $service; | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
module/Core/src/Queue/Controller/MongoQueueListController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2019 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
/** */ | ||
namespace Core\Queue\Controller; | ||
|
||
use Core\Queue\MongoQueue; | ||
use SlmQueue\Queue\QueuePluginManager; | ||
use Zend\Mvc\Console\Controller\AbstractConsoleController; | ||
|
||
/** | ||
* Console controller for list queue jobs. | ||
* | ||
* @author Mathias Gelhausen <gelhausen@cross-solution.de> | ||
*/ | ||
class MongoQueueListController extends AbstractConsoleController | ||
{ | ||
/** | ||
* The queue plugin manager | ||
* | ||
* @var QueuePluginManager | ||
*/ | ||
private $queuePluginManager; | ||
|
||
/** | ||
* MongoQueueListController constructor. | ||
* | ||
* @param QueuePluginManager $queuePluginManager | ||
*/ | ||
public function __construct(QueuePluginManager $queuePluginManager) | ||
{ | ||
$this->queuePluginManager = $queuePluginManager; | ||
} | ||
|
||
/** | ||
* List jobs from a queue | ||
* | ||
* @return string | ||
*/ | ||
public function listAction() | ||
{ | ||
$queue = $this->params()->fromRoute('queue'); | ||
$queue = $this->queuePluginManager->get($queue); | ||
|
||
if (!$queue instanceOf MongoQueue) { | ||
return 'Unsupported queue type.'; | ||
} | ||
|
||
$statusMap = function($stat) { | ||
static $map = [ | ||
'pending' => MongoQueue::STATUS_PENDING, | ||
'running' => MongoQueue::STATUS_RUNNING, | ||
'failed' => MongoQueue::STATUS_FAILED, | ||
]; | ||
|
||
return $map[$stat] ?? $map['pending']; | ||
}; | ||
|
||
$console = $this->getConsole(); | ||
$jobs = $queue->listing([ | ||
'limit' => (int) $this->params()->fromRoute('limit', 0), | ||
'status' => $statusMap($this->params()->fromRoute('status')), | ||
]); | ||
|
||
if (!$jobs) { | ||
return 'Queue is empty.'; | ||
} | ||
|
||
$lineTmpl = '%-20s %s'; | ||
foreach ($jobs as $job) { | ||
$console->writeLine(get_class($job['job']) . ' [ ' . $job['job']->getId() . ' ]'); | ||
|
||
foreach (['created', 'executed', 'scheduled'] as $key) { | ||
$console->writeLine(sprintf($lineTmpl, ucFirst($key), $job[$key]->toDateTime()->format('Y-m-d H:i:s'))); | ||
} | ||
$console->writeLine(sprintf($lineTmpl, 'Tries', $job['tried'])); | ||
$console->writeLine(); | ||
$console->writeLine(); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
module/Core/src/Queue/Controller/MongoQueueListControllerFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* YAWIK | ||
* | ||
* @filesource | ||
* @license MIT | ||
* @copyright 2013 - 2019 Cross Solution <http://cross-solution.de> | ||
*/ | ||
|
||
/** */ | ||
namespace Core\Queue\Controller; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use SlmQueue\Queue\QueuePluginManager; | ||
use Zend\ServiceManager\Factory\FactoryInterface; | ||
|
||
/** | ||
* Factory for \Core\Queue\Controller\MongoQueueListController | ||
* | ||
* @author Mathias Gelhausen <gelhausen@cross-solution.de> | ||
* @todo write test | ||
*/ | ||
class MongoQueueListControllerFactory implements FactoryInterface | ||
{ | ||
|
||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) | ||
{ | ||
$service = new MongoQueueListController( | ||
$container->get(QueuePluginManager::class) | ||
); | ||
|
||
return $service; | ||
} | ||
} |
Oops, something went wrong.