Update tasks service provider

This commit is contained in:
Romain Neutron
2013-10-03 16:49:06 +02:00
parent 49c01c6417
commit 7a7d558b38
2 changed files with 35 additions and 0 deletions

View File

@@ -20,8 +20,10 @@ use Alchemy\Phrasea\TaskManager\Job\RecordMoverJob;
use Alchemy\Phrasea\TaskManager\Job\SubdefsJob; use Alchemy\Phrasea\TaskManager\Job\SubdefsJob;
use Alchemy\Phrasea\TaskManager\Job\WriteMetadataJob; use Alchemy\Phrasea\TaskManager\Job\WriteMetadataJob;
use Alchemy\Phrasea\TaskManager\Job\Factory as JobFactory; use Alchemy\Phrasea\TaskManager\Job\Factory as JobFactory;
use Alchemy\Phrasea\TaskManager\LiveInformation;
use Alchemy\Phrasea\TaskManager\TaskManagerStatus; use Alchemy\Phrasea\TaskManager\TaskManagerStatus;
use Alchemy\Phrasea\TaskManager\Log\LogFileFactory; use Alchemy\Phrasea\TaskManager\Log\LogFileFactory;
use Alchemy\Phrasea\TaskManager\Notifier;
use Silex\Application; use Silex\Application;
use Silex\ServiceProviderInterface; use Silex\ServiceProviderInterface;
@@ -29,6 +31,25 @@ class TasksServiceProvider implements ServiceProviderInterface
{ {
public function register(Application $app) public function register(Application $app)
{ {
$app['task-manager.notifier'] = $app->share(function(Application $app) {
return Notifier::create($app['task-manager.listener.options']);
});
$app['task-manager.listener.options'] = $app->share(function(Application $app) {
if (isset($app['phraseanet.configuration']['task-manager']) && isset($app['phraseanet.configuration']['task-manager']['listener'])) {
$listenerConf = $app['phraseanet.configuration']['task-manager']['listener'];
} else {
$listenerConf = array();
}
return array_replace(array(
'protocol' => 'tcp',
'host' => '127.0.0.1',
'port' => 6660,
'linger' => 500,
), $listenerConf);
});
$app['task-manager.job-factory'] = $app->share(function(Application $app) { $app['task-manager.job-factory'] = $app->share(function(Application $app) {
return new JobFactory($app['dispatcher'],isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['logger']); return new JobFactory($app['dispatcher'],isset($app['task-manager.logger']) ? $app['task-manager.logger'] : $app['logger']);
}); });
@@ -37,6 +58,10 @@ class TasksServiceProvider implements ServiceProviderInterface
return new TaskManagerStatus($app['phraseanet.configuration']); return new TaskManagerStatus($app['phraseanet.configuration']);
}); });
$app['task-manager.live-information'] = $app->share(function(Application $app) {
return new LiveInformation($app['task-manager.status'], $app['task-manager.notifier']);
});
$app['task-manager.log-file.root'] = $app->share(function (Application $app) { $app['task-manager.log-file.root'] = $app->share(function (Application $app) {
return $app['root.path'].'/logs'; return $app['root.path'].'/logs';
}); });

View File

@@ -25,6 +25,16 @@ class TasksServiceProviderTest extends ServiceProviderTestCase
'task-manager.log-file.factory', 'task-manager.log-file.factory',
'Alchemy\Phrasea\TaskManager\Log\LogFileFactory' 'Alchemy\Phrasea\TaskManager\Log\LogFileFactory'
), ),
array(
'Alchemy\Phrasea\Core\Provider\TasksServiceProvider',
'task-manager.notifier',
'Alchemy\Phrasea\TaskManager\Notifier'
),
array(
'Alchemy\Phrasea\Core\Provider\TasksServiceProvider',
'task-manager.live-information',
'Alchemy\Phrasea\TaskManager\LiveInformation'
),
); );
} }