Skip to content

Commit ff4a807

Browse files
removed strategy from locking configuration
1 parent 7c037c4 commit ff4a807

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function getConfigTreeBuilder()
6767
->values(array_keys($this->lockingStorageAliases))
6868
->defaultValue('file')
6969
->end()
70+
->integerNode('ttl')->defaultValue(600)->end()
7071
->arrayNode('storages')
7172
->addDefaultsIfNotSet()
7273
->children()

src/DependencyInjection/TaskExtension.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function load(array $configs, ContainerBuilder $container)
5353
}
5454

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

5959
/**
@@ -82,14 +82,16 @@ private function loadDoctrineAdapter(array $config, ContainerBuilder $container)
8282
*
8383
* @param array $config
8484
* @param LoaderInterface $loader
85+
* @param ContainerBuilder $container
8586
*/
86-
private function loadLockingComponent(array $config, LoaderInterface $loader)
87+
private function loadLockingComponent(array $config, ContainerBuilder $container, LoaderInterface $loader)
8788
{
8889
if (!$config['enabled']) {
8990
return $loader->load('locking/null.xml');
9091
}
9192

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

9597
/**

src/Locking/NullLock.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Task\TaskBundle\Locking;
1313

14-
use Task\Execution\TaskExecutionInterface;
1514
use Task\Lock\LockInterface;
1615

1716
/**
@@ -22,31 +21,31 @@ class NullLock implements LockInterface
2221
/**
2322
* {@inheritdoc}
2423
*/
25-
public function acquire(TaskExecutionInterface $execution)
24+
public function acquire($task)
2625
{
2726
return true;
2827
}
2928

3029
/**
3130
* {@inheritdoc}
3231
*/
33-
public function refresh(TaskExecutionInterface $execution)
32+
public function refresh($task)
3433
{
3534
return true;
3635
}
3736

3837
/**
3938
* {@inheritdoc}
4039
*/
41-
public function release(TaskExecutionInterface $execution)
40+
public function release($task)
4241
{
4342
return true;
4443
}
4544

4645
/**
4746
* {@inheritdoc}
4847
*/
49-
public function isAcquired(TaskExecutionInterface $execution)
48+
public function isAcquired($task)
5049
{
5150
return false;
5251
}

src/Resources/config/locking/services.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
55
<services>
6-
<service id="task.lock.strategy" class="Task\Lock\Strategy\HandlerClassStrategy"/>
7-
86
<service id="task.lock" class="Task\Lock\Lock">
9-
<argument type="service" id="task.lock.strategy"/>
107
<argument type="service" id="task.lock.storage"/>
8+
<argument>%task.lock.ttl%</argument>
119
</service>
1210
</services>
1311
</container>

tests/Functional/Command/ScheduleTaskCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testExecuteWithWorkloadAndIntervalAndEndDate()
9494
$this->assertEquals(TestHandler::class, $tasks[0]->getHandlerClass());
9595
$this->assertEquals('Test workload 1', $tasks[0]->getWorkload());
9696
$this->assertEquals('0 * * * *', $tasks[0]->getInterval());
97-
$this->assertEquals($date, $tasks[0]->getLastExecution());
97+
$this->assertEquals($date, $tasks[0]->getLastExecution(), '', 2);
9898
}
9999

100100
public function testExecuteWithExecutionDate()

0 commit comments

Comments
 (0)