Batch queue

This commit is contained in:
Juan Pablo Vial
2025-06-30 15:52:28 -04:00
parent 5f4d8a4bc2
commit d4f8804fbb
29 changed files with 525 additions and 134 deletions

View File

@ -3,8 +3,9 @@ use Psr\Container\ContainerInterface;
return [
Incoviba\Service\Login::class => function(ContainerInterface $container) {
$uri = $container->has('API_URL') ? $container->get('API_URL') : 'http://proxy/api';
$client = new GuzzleHttp\Client([
'base_uri' => $container->has('API_URL') ? $container->get('API_URL') : 'http://proxy/api',
'base_uri' => $uri,
'headers' => [
'Authorization' => [
'Bearer ' . md5($container->get('API_KEY'))

View File

@ -19,5 +19,13 @@ return [
$container->get(DateTimeZone::class),
$container->get('loopFrequency'),
);
},
Incoviba\Command\Queue::class => function(ContainerInterface $container) {
return new Incoviba\Command\Queue(
$container->get(Psr\Http\Client\ClientInterface::class),
$container->get('QueueLogger'),
$container->get(Incoviba\Service\Job::class),
$container->get(DateTimeZone::class)
);
}
];

View File

@ -64,27 +64,63 @@ return [
], $container->get(DateTimeZone::class));
},
'LoopLogger' => function(ContainerInterface $container) {
return new Monolog\Logger('loop', [
new Monolog\Handler\FilterHandler(
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
? new Monolog\Handler\StreamHandler('/logs/loop-error.log')
: new Monolog\Handler\RotatingFileHandler('/logs/loop-error.log', 10),
$handlers = [
'warning' => new Monolog\Handler\FilterHandler(
new Monolog\Handler\RotatingFileHandler('/logs/loop-error.log', 10),
Monolog\Level::Warning
),
new Monolog\Handler\FilterHandler(
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
? new Monolog\Handler\StreamHandler('/logs/loop.log')
: new Monolog\Handler\RotatingFileHandler('/logs/loop.log', 10),
'notice' => new Monolog\Handler\FilterHandler(
new Monolog\Handler\RotatingFileHandler('/logs/loop.log', 10),
Monolog\Level::Notice,
Monolog\Level::Notice
),
new Monolog\Handler\FilterHandler(
($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development')
? new Monolog\Handler\StreamHandler('/logs/loop-debug.log')
: new Monolog\Handler\RotatingFileHandler('/logs/loop-debug.log', 10),
'debug' => new Monolog\Handler\FilterHandler(
new Monolog\Handler\RotatingFileHandler('/logs/loop-debug.log', 10),
Monolog\Level::Debug,
Monolog\Level::Debug
)
], [], $container->get(DateTimeZone::class));
];
if ($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development') {
$handlers['warning'] = new Monolog\Handler\FilterHandler(
new Monolog\Handler\StreamHandler('/logs/loop-error.log'),
Monolog\Level::Warning);
$handlers['notice'] = new Monolog\Handler\FilterHandler(
new Monolog\Handler\StreamHandler('/logs/loop.log'),
Monolog\Level::Notice, Monolog\Level::Notice);
$handlers['debug'] = new Monolog\Handler\FilterHandler(
new Monolog\Handler\StreamHandler('/logs/loop-debug.log'),
Monolog\Level::Debug, Monolog\Level::Debug);
}
return new Monolog\Logger('loop', $handlers, [], $container->get(DateTimeZone::class));
},
'QueueLogger' => function(ContainerInterface $container) {
$handlers = [
'warning' => new Monolog\Handler\FilterHandler(
new Monolog\Handler\RotatingFileHandler('/logs/queue-error.log', 10),
Monolog\Level::Warning
),
'notice' => new Monolog\Handler\FilterHandler(
new Monolog\Handler\RotatingFileHandler('/logs/queue.log', 10),
Monolog\Level::Notice,
Monolog\Level::Notice
),
'debug' => new Monolog\Handler\FilterHandler(
new Monolog\Handler\RotatingFileHandler('/logs/queue-debug.log', 10),
Monolog\Level::Debug,
Monolog\Level::Debug
)
];
if ($container->has('ENVIRONMENT') and $container->get('ENVIRONMENT') === 'development') {
$handlers['warning'] = new Monolog\Handler\FilterHandler(
new Monolog\Handler\StreamHandler('/logs/queue-error.log'),
Monolog\Level::Warning);
$handlers['notice'] = new Monolog\Handler\FilterHandler(
new Monolog\Handler\StreamHandler('/logs/queue.log'),
Monolog\Level::Notice, Monolog\Level::Notice);
$handlers['debug'] = new Monolog\Handler\FilterHandler(
new Monolog\Handler\StreamHandler('/logs/queue-debug.log'),
Monolog\Level::Debug, Monolog\Level::Debug);
}
return new Monolog\Logger('queue', $handlers, [], $container->get(DateTimeZone::class));
}
];