diff --git a/bin/console b/bin/console index 0fe46b128c..3b424b32c3 100755 --- a/bin/console +++ b/bin/console @@ -130,6 +130,10 @@ $cli->command(new QueryParseCommand()); $cli->command(new QuerySampleCommand()); $cli->command(new FindConceptsCommand()); +$cli->command($cli['alchemy_worker.commands.run_dispatcher_command']); +$cli->command($cli['alchemy_worker.commands.run_worker_command']); +$cli->command($cli['alchemy_worker.commands.show_configuration']); + $cli->loadPlugins(); exit(is_int($cli->run()) ? : 1); diff --git a/composer.json b/composer.json index 41ff3a11cb..6559cb6f95 100644 --- a/composer.json +++ b/composer.json @@ -100,7 +100,9 @@ "vierbergenlars/php-semver": "~2.1", "webmozart/json": "^1.1", "willdurand/negotiation": "^2.0.0-alpha1", - "zend/gdata": "~1.12.1" + "zend/gdata": "~1.12.1", + "alchemy/worker-bundle": "^0.1.0", + "alchemy/queue-bundle": "^0.1.4" }, "require-dev": { "mikey179/vfsStream": "~1.5", diff --git a/composer.lock b/composer.lock index 3ab4b47e7b..86a213731b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e87832949ae7b20d258aceb271577c5c", - "content-hash": "35f87700aa4cbe3c2903fe166676cc74", + "hash": "c70a62cc23f92cacbbc4ae5af8a6c3d6", + "content-hash": "56c893eb601ef1711af8b4a086c0f5de", "packages": [ { "name": "alchemy-fr/tcpdf-clone", @@ -486,6 +486,99 @@ ], "time": "2015-11-30 14:00:23" }, + { + "name": "alchemy/queue-bundle", + "version": "0.1.4", + "source": { + "type": "git", + "url": "https://github.com/alchemy-fr/queue-bundle.git", + "reference": "adcae68fe36888a47bcb57ed6af6997767eb2ac8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alchemy-fr/queue-bundle/zipball/adcae68fe36888a47bcb57ed6af6997767eb2ac8", + "reference": "adcae68fe36888a47bcb57ed6af6997767eb2ac8", + "shasum": "" + }, + "require": { + "alchemy/queue-component": "^0.1.4", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^5.4", + "silex/silex": "^1.3.0", + "symfony/symfony": "^2.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Alchemy\\QueueBundle\\": "src/QueueBundle", + "Alchemy\\QueueProvider\\": "src/QueueProvider" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + } + ], + "description": "Symfony bundle for alchemy/queue-component", + "time": "2016-10-03 15:15:29" + }, + { + "name": "alchemy/queue-component", + "version": "0.1.4", + "source": { + "type": "git", + "url": "https://github.com/alchemy-fr/queue-component.git", + "reference": "f8d6d2e28fcee26af338007d614632c31d4e1477" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alchemy-fr/queue-component/zipball/f8d6d2e28fcee26af338007d614632c31d4e1477", + "reference": "f8d6d2e28fcee26af338007d614632c31d4e1477", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "psr/log": "^1.0", + "ramsey/uuid": "^3.3" + }, + "require-dev": { + "empi89/php-amqp-stubs": "dev-master", + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^4.0|^5.0" + }, + "suggest": { + "ext-amqp": "To use the AMQP extension adapters" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Alchemy\\Queue\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Message queue component", + "time": "2016-10-03 08:13:30" + }, { "name": "alchemy/rest-bundle", "version": "0.0.5", @@ -648,6 +741,100 @@ ], "time": "2016-03-11 12:13:53" }, + { + "name": "alchemy/worker-bundle", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/alchemy-fr/worker-bundle.git", + "reference": "eb8eef5407d1413e3ca5249db3b9bc8236027bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alchemy-fr/worker-bundle/zipball/eb8eef5407d1413e3ca5249db3b9bc8236027bf8", + "reference": "eb8eef5407d1413e3ca5249db3b9bc8236027bf8", + "shasum": "" + }, + "require": { + "alchemy/worker-component": "^0.1.0", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^5.4", + "silex/silex": "^1.3.0", + "symfony/symfony": "^2.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Alchemy\\WorkerBundle\\": "src/WorkerBundle", + "Alchemy\\WorkerProvider\\": "src/WorkerProvider" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Thibaud Fabre", + "email": "thibaud@aztech.io" + } + ], + "description": "Symfony bundle for alchemy/worker-component", + "time": "2016-10-03 09:54:46" + }, + { + "name": "alchemy/worker-component", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/alchemy-fr/worker-component.git", + "reference": "ec04aefd7bb5777b8f7a834f82e8ede2d651ce46" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alchemy-fr/worker-component/zipball/ec04aefd7bb5777b8f7a834f82e8ede2d651ce46", + "reference": "ec04aefd7bb5777b8f7a834f82e8ede2d651ce46", + "shasum": "" + }, + "require": { + "alchemy/queue-component": "^0.1.4", + "php": ">=5.5", + "psr/log": "^1.0", + "ramsey/uuid": "^3.3" + }, + "require-dev": { + "empi89/php-amqp-stubs": "dev-master", + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^4.0|^5.0" + }, + "suggest": { + "ext-amqp": "To use the AMQP extension adapters" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Alchemy\\Worker\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Message queue worker component", + "time": "2016-10-03 08:24:51" + }, { "name": "alchemy/zippy", "version": "0.3.5", diff --git a/lib/Alchemy/Phrasea/CLI.php b/lib/Alchemy/Phrasea/CLI.php index e5a10eac5e..f88f8eab05 100644 --- a/lib/Alchemy/Phrasea/CLI.php +++ b/lib/Alchemy/Phrasea/CLI.php @@ -15,7 +15,10 @@ use Alchemy\Phrasea\Command\CommandInterface; use Alchemy\Phrasea\Core\CLIProvider\TranslationExtractorServiceProvider; use Alchemy\Phrasea\Core\Event\Subscriber\BridgeSubscriber; use Alchemy\Phrasea\Core\PhraseaCLIExceptionHandler; +use Alchemy\Phrasea\Core\Provider\WorkerConfigurationServiceProvider; use Alchemy\Phrasea\Exception\RuntimeException; +use Alchemy\QueueProvider\QueueServiceProvider; +use Alchemy\WorkerProvider\WorkerServiceProvider; use Symfony\Component\Console; use Alchemy\Phrasea\Core\CLIProvider\CLIDriversServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\ComposerSetupServiceProvider; @@ -23,6 +26,7 @@ use Alchemy\Phrasea\Core\CLIProvider\DoctrineMigrationServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\PluginServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\SignalHandlerServiceProvider; use Alchemy\Phrasea\Core\CLIProvider\TaskManagerServiceProvider; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\EventDispatcher\EventDispatcher; @@ -69,6 +73,9 @@ class CLI extends Application $this->register(new TaskManagerServiceProvider()); $this->register(new TranslationExtractorServiceProvider()); $this->register(new DoctrineMigrationServiceProvider()); + $this->register(new QueueServiceProvider()); + $this->register(new WorkerServiceProvider()); + $this->register(new WorkerConfigurationServiceProvider()); $this->bindRoutes(); @@ -115,11 +122,14 @@ class CLI extends Application * * If a command with the same name already exists, it will be overridden. * - * @param CommandInterface $command A Command object + * @param Command|CommandInterface $command A Command object */ - public function command(CommandInterface $command) + public function command($command) { - $command->setContainer($this); + if ($command instanceof CommandInterface) { + $command->setContainer($this); + } + $this['console']->add($command); } diff --git a/lib/Alchemy/Phrasea/Command/CommandInterface.php b/lib/Alchemy/Phrasea/Command/CommandInterface.php index 241adf4897..cfb7c91cb4 100644 --- a/lib/Alchemy/Phrasea/Command/CommandInterface.php +++ b/lib/Alchemy/Phrasea/Command/CommandInterface.php @@ -24,6 +24,8 @@ interface CommandInterface /** * Factory for the command. + * + * @deprecated Will be removed in a future release. */ public static function create(); } diff --git a/lib/Alchemy/Phrasea/Core/Provider/WorkerConfigurationServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/WorkerConfigurationServiceProvider.php new file mode 100644 index 0000000000..e979661ffd --- /dev/null +++ b/lib/Alchemy/Phrasea/Core/Provider/WorkerConfigurationServiceProvider.php @@ -0,0 +1,43 @@ +share(function (Application $app) { + return [ + 'worker-queue' => [ + 'registry' => 'alchemy_worker.queue_registry', + 'host' => 'localhost', + 'port' => 5672, + 'user' => 'guest', + 'vhost' => '/' + ] + ]; + }); + } + + /** + * Bootstraps the application. + * + * This method is called after all services are registered + * and should be used for "dynamic" configuration (whenever + * a service must be requested). + */ + public function boot(Application $app) + { + // TODO: Implement boot() method. + } +}