Skip to content

Commit

Permalink
removed strategy from locking configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed May 15, 2017
1 parent 7c037c4 commit ff4a807
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function getConfigTreeBuilder()
->values(array_keys($this->lockingStorageAliases))
->defaultValue('file')
->end()
->integerNode('ttl')->defaultValue(600)->end()
->arrayNode('storages')
->addDefaultsIfNotSet()
->children()
Expand Down
6 changes: 4 additions & 2 deletions src/DependencyInjection/TaskExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function load(array $configs, ContainerBuilder $container)
}

$this->loadDoctrineAdapter($config['adapters']['doctrine'], $container);
$this->loadLockingComponent($config['locking'], $loader);
$this->loadLockingComponent($config['locking'], $container, $loader);
}

/**
Expand Down Expand Up @@ -82,14 +82,16 @@ private function loadDoctrineAdapter(array $config, ContainerBuilder $container)
*
* @param array $config
* @param LoaderInterface $loader
* @param ContainerBuilder $container
*/
private function loadLockingComponent(array $config, LoaderInterface $loader)
private function loadLockingComponent(array $config, ContainerBuilder $container, LoaderInterface $loader)
{
if (!$config['enabled']) {
return $loader->load('locking/null.xml');
}

$loader->load('locking/services.xml');
$container->setParameter('task.lock.ttl', $config['ttl']);
}

/**
Expand Down
9 changes: 4 additions & 5 deletions src/Locking/NullLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Task\TaskBundle\Locking;

use Task\Execution\TaskExecutionInterface;
use Task\Lock\LockInterface;

/**
Expand All @@ -22,31 +21,31 @@ class NullLock implements LockInterface
/**
* {@inheritdoc}
*/
public function acquire(TaskExecutionInterface $execution)
public function acquire($task)
{
return true;
}

/**
* {@inheritdoc}
*/
public function refresh(TaskExecutionInterface $execution)
public function refresh($task)
{
return true;
}

/**
* {@inheritdoc}
*/
public function release(TaskExecutionInterface $execution)
public function release($task)
{
return true;
}

/**
* {@inheritdoc}
*/
public function isAcquired(TaskExecutionInterface $execution)
public function isAcquired($task)
{
return false;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Resources/config/locking/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="task.lock.strategy" class="Task\Lock\Strategy\HandlerClassStrategy"/>

<service id="task.lock" class="Task\Lock\Lock">
<argument type="service" id="task.lock.strategy"/>
<argument type="service" id="task.lock.storage"/>
<argument>%task.lock.ttl%</argument>
</service>
</services>
</container>
2 changes: 1 addition & 1 deletion tests/Functional/Command/ScheduleTaskCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testExecuteWithWorkloadAndIntervalAndEndDate()
$this->assertEquals(TestHandler::class, $tasks[0]->getHandlerClass());
$this->assertEquals('Test workload 1', $tasks[0]->getWorkload());
$this->assertEquals('0 * * * *', $tasks[0]->getInterval());
$this->assertEquals($date, $tasks[0]->getLastExecution());
$this->assertEquals($date, $tasks[0]->getLastExecution(), '', 2);
}

public function testExecuteWithExecutionDate()
Expand Down

0 comments on commit ff4a807

Please sign in to comment.