Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add check for LiipMonitoring-Bundle (WIP) #61

Open
wants to merge 3 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"doctrine/doctrine-bundle": "^2.10",
"doctrine/orm": "^2.15",
"knplabs/knp-time-bundle": "^1.20|^2.0",
"liip/monitor-bundle": "3.x-dev",
Chris53897 marked this conversation as resolved.
Show resolved Hide resolved
"lorisleiva/cron-translator": "^0.4.3",
"matthiasnoback/symfony-dependency-injection-test": "^4.3|^5.0",
"phpstan/phpstan": "^1.4",
Expand Down
7 changes: 7 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Zenstruck\Messenger\Monitor\Worker\WorkerCache;
use Zenstruck\Messenger\Monitor\Worker\WorkerListener;
use Zenstruck\Messenger\Monitor\Workers;
use Zenstruck\Messenger\Monitor\Check\WorkerRunningCheck;

return static function (ContainerConfigurator $container): void {
$container->services()
Expand Down Expand Up @@ -57,5 +58,11 @@
service('time.datetime_formatter')->nullOnInvalid(),
])
->alias(ViewHelper::class, 'zenstruck_messenger_monitor.view_helper')

->set('zenstruck_messenger_monitor.worker_running_check', WorkerRunningCheck::class)
->args([
service('.zenstruck_messenger_monitor.worker_cache'),
])
->alias(WorkerRunningCheck::class, 'zenstruck_messenger_monitor.worker_running_check')
;
};
82 changes: 82 additions & 0 deletions src/Check/WorkerRunningCheck.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

/*
* This file is part of the zenstruck/messenger-monitor-bundle package.
*
* (c) Kevin Bond <kevinbond@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Zenstruck\Messenger\Monitor\Check;

use Liip\Monitor\Check;
use Liip\Monitor\Result;
use Zenstruck\Messenger\Monitor\Worker\WorkerCache;
use Liip\Monitor\AsCheck;

#[AsCheck(id: 'symfony_worker_running', suite: 'messenger-monitoring')]
class WorkerRunningCheck implements Check, \Stringable
{
public function __construct(private WorkerCache $workerCache)

Check failure on line 22 in src/Check/WorkerRunningCheck.php

View workflow job for this annotation

GitHub Actions / sca / Static Code Analysis

Property Zenstruck\Messenger\Monitor\Check\WorkerRunningCheck::$workerCache is never read, only written.
{}

public function __toString(): string
{
return 'symfony_worker_running';
#return 'Symfony Workers running';
}

public function run(): Result
{

#$this->workerCache->getIterator();

/*
if ($this->version->isEol()) {
return Result::failure(
\sprintf('%s - the %s branch is EOL', $this->version->currentVersion(), $this->version->branch()),
context: ['eol_date' => $this->version->supportUntil()]
);
}

if ($this->version->isPatchUpdateRequired()) {
return Result::warning(
\sprintf('%s - requires a patch update to %s', $this->version->currentVersion(), $this->version->latestPatchVersion()),
context: ['latest_patch_version' => $this->version->latestPatchVersion()]
);
}*/

return Result::success("Actual running: ". 2);
}

public static function configInfo(): ?string
{
return 'check if the minimum amount of symfony workers is running';
}

protected function detail(): string
{
return 'Details';
#return \sprintf('Disk (%s) is %s used (%s of %s total)', $this->path, $storage->percentUsed(), $storage->used(), $storage->total());
}

/*
public static function load(array $config, ContainerBuilder $container): void
{
if (!$config['enabled']) {
return;
}

var_dump("AAAAA");

$container->register(\sprintf('.liip_monitor.check.%s', static::configKey()), static::class)
->setArguments([
new Reference('liip_monitor.info.symfony_worker_running'),
])
->addTag('liip_monitor.check', $config);
}*/
}


Loading