PHPCBF run
This commit is contained in:
parent
16777f1daf
commit
42dd283690
10 changed files with 28 additions and 29 deletions
|
@ -84,18 +84,17 @@ class MessengerCommandController extends CommandController
|
||||||
$this->receiverContainer,
|
$this->receiverContainer,
|
||||||
$this->eventDispatcher,
|
$this->eventDispatcher,
|
||||||
$this->logger,
|
$this->logger,
|
||||||
array_keys($this->configuration['transports'])
|
\array_keys($this->configuration['transports'])
|
||||||
);
|
);
|
||||||
$this->run($command);
|
$this->run($command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List all available receivers
|
* List all available receivers
|
||||||
*/
|
*/
|
||||||
public function listReceiversCommand()
|
public function listReceiversCommand()
|
||||||
{
|
{
|
||||||
foreach (array_keys($this->configuration['transports']) as $transportName) {
|
foreach (\array_keys($this->configuration['transports']) as $transportName) {
|
||||||
$this->outputLine('- ' . $transportName);
|
$this->outputLine('- ' . $transportName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +111,7 @@ class MessengerCommandController extends CommandController
|
||||||
$cacheItem = $this->restartSignalCachePool->getItem(
|
$cacheItem = $this->restartSignalCachePool->getItem(
|
||||||
StopWorkerOnRestartSignalListener::RESTART_REQUESTED_TIMESTAMP_KEY
|
StopWorkerOnRestartSignalListener::RESTART_REQUESTED_TIMESTAMP_KEY
|
||||||
);
|
);
|
||||||
$cacheItem->set(microtime(true));
|
$cacheItem->set(\microtime(true));
|
||||||
$this->restartSignalCachePool->save($cacheItem);
|
$this->restartSignalCachePool->save($cacheItem);
|
||||||
|
|
||||||
//TODO: Add the possibility to wait until all are exited
|
//TODO: Add the possibility to wait until all are exited
|
||||||
|
|
|
@ -13,11 +13,11 @@ trait RunSymfonyCommandTrait
|
||||||
protected function run(Command $command)
|
protected function run(Command $command)
|
||||||
{
|
{
|
||||||
$definition = $command->getDefinition();
|
$definition = $command->getDefinition();
|
||||||
$definition->setArguments(array_merge(
|
$definition->setArguments(\array_merge(
|
||||||
[new InputArgument('command', InputArgument::REQUIRED)],
|
[new InputArgument('command', InputArgument::REQUIRED)],
|
||||||
$definition->getArguments()
|
$definition->getArguments()
|
||||||
));
|
));
|
||||||
$definition->setOptions(array_merge(
|
$definition->setOptions(\array_merge(
|
||||||
[
|
[
|
||||||
new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
|
new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'),
|
||||||
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
|
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
|
||||||
|
@ -31,7 +31,7 @@ trait RunSymfonyCommandTrait
|
||||||
|
|
||||||
protected function configureIO($input, $output)
|
protected function configureIO($input, $output)
|
||||||
{
|
{
|
||||||
switch ($shellVerbosity = (int) getenv('SHELL_VERBOSITY')) {
|
switch ($shellVerbosity = (int)\getenv('SHELL_VERBOSITY')) {
|
||||||
case -1:
|
case -1:
|
||||||
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
||||||
break;
|
break;
|
||||||
|
@ -82,7 +82,7 @@ trait RunSymfonyCommandTrait
|
||||||
$input->setInteractive(false);
|
$input->setInteractive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
putenv('SHELL_VERBOSITY=' . $shellVerbosity);
|
\putenv('SHELL_VERBOSITY=' . $shellVerbosity);
|
||||||
$_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
|
$_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
|
||||||
$_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
|
$_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ class EventDispatcherFactory
|
||||||
$eventDispatcher = new EventDispatcher();
|
$eventDispatcher = new EventDispatcher();
|
||||||
|
|
||||||
foreach ($this->configuration['eventDispatcher']['subscribers'] as $subscriberId => $enabled) {
|
foreach ($this->configuration['eventDispatcher']['subscribers'] as $subscriberId => $enabled) {
|
||||||
if ($subscriberId === null || ! (bool) $enabled) {
|
if ($subscriberId === null || ! (bool)$enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->addLazySubscribers($eventDispatcher, $subscriberId);
|
$this->addLazySubscribers($eventDispatcher, $subscriberId);
|
||||||
|
@ -39,7 +39,7 @@ class EventDispatcherFactory
|
||||||
private function addLazySubscribers(EventDispatcherInterface $eventDispatcher, $subscriberId)
|
private function addLazySubscribers(EventDispatcherInterface $eventDispatcher, $subscriberId)
|
||||||
{
|
{
|
||||||
$subscriberClass = $this->objectManager->getClassNameByObjectName($subscriberId);
|
$subscriberClass = $this->objectManager->getClassNameByObjectName($subscriberId);
|
||||||
if (! is_a($subscriberClass, EventSubscriberInterface::class, true)) {
|
if (! \is_a($subscriberClass, EventSubscriberInterface::class, true)) {
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
'Object with name ' . $subscriberId . ' is not an EventSubscriberInterface',
|
'Object with name ' . $subscriberId . ' is not an EventSubscriberInterface',
|
||||||
1618753949
|
1618753949
|
||||||
|
|
|
@ -35,7 +35,7 @@ class StopWorkerOnRestartSignalListener implements EventSubscriberInterface
|
||||||
|
|
||||||
public function onWorkerStarted(): void
|
public function onWorkerStarted(): void
|
||||||
{
|
{
|
||||||
$this->workerStartedAt = microtime(true);
|
$this->workerStartedAt = \microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onWorkerRunning(WorkerRunningEvent $event): void
|
public function onWorkerRunning(WorkerRunningEvent $event): void
|
||||||
|
|
|
@ -36,7 +36,7 @@ class HandlersLocatorFactory
|
||||||
$handlerDescriptors = [];
|
$handlerDescriptors = [];
|
||||||
foreach ($messageHandlerClasses as $messageHandlerClass) {
|
foreach ($messageHandlerClasses as $messageHandlerClass) {
|
||||||
foreach ($messageHandlerClass::getHandledMessages() as $messageName => $config) {
|
foreach ($messageHandlerClass::getHandledMessages() as $messageName => $config) {
|
||||||
if (! is_array($config)) {
|
if (! \is_array($config)) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
'different from doctrine, we (currently) need subscribers to always have an option array'
|
'different from doctrine, we (currently) need subscribers to always have an option array'
|
||||||
);
|
);
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RewindableGenerator implements \IteratorAggregate, \Countable
|
||||||
public function __construct(array $serviceIds)
|
public function __construct(array $serviceIds)
|
||||||
{
|
{
|
||||||
$this->serviceIds = $serviceIds;
|
$this->serviceIds = $serviceIds;
|
||||||
$sortedServiceIds = array_keys(
|
$sortedServiceIds = \array_keys(
|
||||||
(new PositionalArraySorter($serviceIds))->toArray()
|
(new PositionalArraySorter($serviceIds))->toArray()
|
||||||
);
|
);
|
||||||
$this->generator = function () use ($sortedServiceIds) {
|
$this->generator = function () use ($sortedServiceIds) {
|
||||||
|
@ -38,7 +38,7 @@ class RewindableGenerator implements \IteratorAggregate, \Countable
|
||||||
}
|
}
|
||||||
$object = $this->objectManager->get($serviceId);
|
$object = $this->objectManager->get($serviceId);
|
||||||
// TODO: Thats a quite poor solution to dynamically inject the logger - but it is easy
|
// TODO: Thats a quite poor solution to dynamically inject the logger - but it is easy
|
||||||
if (method_exists($object, 'setLogger')) {
|
if (\method_exists($object, 'setLogger')) {
|
||||||
$object->setLogger($this->objectManager->get(LoggerInterface::class));
|
$object->setLogger($this->objectManager->get(LoggerInterface::class));
|
||||||
}
|
}
|
||||||
yield $object;
|
yield $object;
|
||||||
|
@ -55,6 +55,6 @@ class RewindableGenerator implements \IteratorAggregate, \Countable
|
||||||
|
|
||||||
public function count()
|
public function count()
|
||||||
{
|
{
|
||||||
return count($this->serviceIds);
|
return \count($this->serviceIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class RetryStrategiesContainer implements ContainerInterface
|
||||||
throw new \InvalidArgumentException('Unknown transport name: ' . $id);
|
throw new \InvalidArgumentException('Unknown transport name: ' . $id);
|
||||||
}
|
}
|
||||||
if (! isset($this->retryStrategies[$id])) {
|
if (! isset($this->retryStrategies[$id])) {
|
||||||
$strategyDefinition = array_merge(
|
$strategyDefinition = \array_merge(
|
||||||
$this->configuration['defaultRetryStrategyOptions'],
|
$this->configuration['defaultRetryStrategyOptions'],
|
||||||
$this->configuration['transports'][$id]['retryStrategy'] ?? []
|
$this->configuration['transports'][$id]['retryStrategy'] ?? []
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace DigiComp\FlowSymfonyBridge\Messenger\Transport;
|
||||||
|
|
||||||
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
|
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Neos\Flow\Annotations as Flow;
|
||||||
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
|
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
|
||||||
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransport;
|
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransport;
|
||||||
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\PostgreSqlConnection;
|
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\PostgreSqlConnection;
|
||||||
|
@ -11,7 +12,6 @@ use Symfony\Component\Messenger\Exception\TransportException;
|
||||||
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
|
||||||
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
|
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
|
||||||
use Symfony\Component\Messenger\Transport\TransportInterface;
|
use Symfony\Component\Messenger\Transport\TransportInterface;
|
||||||
use Neos\Flow\Annotations as Flow;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Flow\Scope("singleton")
|
* @Flow\Scope("singleton")
|
||||||
|
@ -36,7 +36,7 @@ class FlowDoctrineTransportFactory implements TransportFactoryInterface
|
||||||
try {
|
try {
|
||||||
$driverConnection = $this->entityManager->getConnection();
|
$driverConnection = $this->entityManager->getConnection();
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
throw new TransportException(sprintf(
|
throw new TransportException(\sprintf(
|
||||||
'Could not find Doctrine connection from Messenger DSN "%s".',
|
'Could not find Doctrine connection from Messenger DSN "%s".',
|
||||||
$dsn
|
$dsn
|
||||||
), 0, $e);
|
), 0, $e);
|
||||||
|
@ -56,6 +56,6 @@ class FlowDoctrineTransportFactory implements TransportFactoryInterface
|
||||||
*/
|
*/
|
||||||
public function supports(string $dsn, array $options): bool
|
public function supports(string $dsn, array $options): bool
|
||||||
{
|
{
|
||||||
return 0 === strpos($dsn, 'flow-doctrine://');
|
return 0 === \strpos($dsn, 'flow-doctrine://');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,6 @@ class NullTransportFactory implements TransportFactoryInterface
|
||||||
*/
|
*/
|
||||||
public function supports(string $dsn, array $options): bool
|
public function supports(string $dsn, array $options): bool
|
||||||
{
|
{
|
||||||
return 0 === strpos($dsn, 'null://');
|
return 0 === \strpos($dsn, 'null://');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,23 +42,23 @@ class TransportsContainer implements ContainerInterface
|
||||||
throw new \InvalidArgumentException('Unknown transport name: ' . $id);
|
throw new \InvalidArgumentException('Unknown transport name: ' . $id);
|
||||||
}
|
}
|
||||||
if (! isset($this->transports[$id])) {
|
if (! isset($this->transports[$id])) {
|
||||||
$transportDefinition = array_merge([
|
$transportDefinition = \array_merge([
|
||||||
'dsn' => '',
|
'dsn' => '',
|
||||||
'options' => [],
|
'options' => [],
|
||||||
'serializer' => $this->configuration['defaultSerializerName'],
|
'serializer' => $this->configuration['defaultSerializerName'],
|
||||||
# TODO: Probably this has to be setup elsewhere, as the transport does not care by itself
|
// TODO: Probably this has to be setup elsewhere, as the transport does not care by itself
|
||||||
'retry_strategy' => [ # TODO: Make the default configurable
|
'retry_strategy' => [ // TODO: Make the default configurable
|
||||||
'max_retries' => 3,
|
'max_retries' => 3,
|
||||||
# milliseconds delay
|
// milliseconds delay
|
||||||
'delay' => 1000,
|
'delay' => 1000,
|
||||||
# causes the delay to be higher before each retry
|
// causes the delay to be higher before each retry
|
||||||
# e.g. 1 second delay, 2 seconds, 4 seconds
|
// e.g. 1 second delay, 2 seconds, 4 seconds
|
||||||
'multiplier' => 2,
|
'multiplier' => 2,
|
||||||
'max_delay' => 0,
|
'max_delay' => 0,
|
||||||
# override all of this with a service that
|
// override all of this with a service that
|
||||||
# implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
|
// implements Symfony\Component\Messenger\Retry\RetryStrategyInterface
|
||||||
'service' => null
|
'service' => null
|
||||||
]
|
],
|
||||||
], $this->configuration['transports'][$id]);
|
], $this->configuration['transports'][$id]);
|
||||||
$this->transports[$id] = $this->transportFactory->createTransport(
|
$this->transports[$id] = $this->transportFactory->createTransport(
|
||||||
$transportDefinition['dsn'],
|
$transportDefinition['dsn'],
|
||||||
|
|
Loading…
Reference in a new issue