Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e9671b

Browse filesBrowse files
committed
Rename Quorum into Strategy
1 parent 59dd752 commit 1e9671b
Copy full SHA for 1e9671b

File tree

7 files changed

+61
-65
lines changed
Filter options

7 files changed

+61
-65
lines changed

‎src/Symfony/Component/Lock/Store/CombinedStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/CombinedStore.php
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\Lock\Exception\LockConflictedException;
1919
use Symfony\Component\Lock\Exception\NotSupportedException;
2020
use Symfony\Component\Lock\Key;
21-
use Symfony\Component\Lock\QuorumInterface;
21+
use Symfony\Component\Lock\Strategy\StrategyInterface;
2222
use Symfony\Component\Lock\StoreInterface;
2323

2424
/**
@@ -32,16 +32,16 @@ class CombinedStore implements StoreInterface, LoggerAwareInterface
3232

3333
/** @var StoreInterface[] */
3434
private $stores;
35-
/** @var QuorumInterface */
36-
private $quorum;
35+
/** @var StrategyInterface */
36+
private $strategy;
3737

3838
/**
39-
* @param StoreInterface[] $stores The list of synchronized stores
40-
* @param QuorumInterface $quorum
39+
* @param StoreInterface[] $stores The list of synchronized stores
40+
* @param StrategyInterface $strategy
4141
*
4242
* @throws InvalidArgumentException
4343
*/
44-
public function __construct(array $stores, QuorumInterface $quorum)
44+
public function __construct(array $stores, StrategyInterface $strategy)
4545
{
4646
foreach ($stores as $store) {
4747
if (!$store instanceof StoreInterface) {
@@ -50,7 +50,7 @@ public function __construct(array $stores, QuorumInterface $quorum)
5050
}
5151

5252
$this->stores = $stores;
53-
$this->quorum = $quorum;
53+
$this->strategy = $strategy;
5454
$this->logger = new NullLogger();
5555
}
5656

@@ -72,12 +72,12 @@ public function save(Key $key)
7272
++$failureCount;
7373
}
7474

75-
if (!$this->quorum->canBeMet($failureCount, $storesCount)) {
75+
if (!$this->strategy->canBeMet($failureCount, $storesCount)) {
7676
break;
7777
}
7878
}
7979

80-
if ($this->quorum->isMet($successCount, $storesCount)) {
80+
if ($this->strategy->isMet($successCount, $storesCount)) {
8181
return;
8282
}
8383

@@ -112,12 +112,12 @@ public function putOffExpiration(Key $key, $ttl)
112112
++$failureCount;
113113
}
114114

115-
if (!$this->quorum->canBeMet($failureCount, $storesCount)) {
115+
if (!$this->strategy->canBeMet($failureCount, $storesCount)) {
116116
break;
117117
}
118118
}
119119

120-
if ($this->quorum->isMet($successCount, $storesCount)) {
120+
if ($this->strategy->isMet($successCount, $storesCount)) {
121121
return;
122122
}
123123

@@ -161,10 +161,10 @@ public function exists(Key $key)
161161
++$failureCount;
162162
}
163163

164-
if ($this->quorum->isMet($successCount, $storesCount)) {
164+
if ($this->strategy->isMet($successCount, $storesCount)) {
165165
return true;
166166
}
167-
if (!$this->quorum->canBeMet($failureCount, $storesCount)) {
167+
if (!$this->strategy->canBeMet($failureCount, $storesCount)) {
168168
return false;
169169
}
170170
}

‎src/Symfony/Component/Lock/Quorum/ConsensusStrategy.php renamed to ‎src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Lock\Quorum;
13-
14-
use Symfony\Component\Lock\QuorumInterface;
12+
namespace Symfony\Component\Lock\Strategy;
1513

1614
/**
17-
* ConsensusStrategy is a QuorumInterface implementation where strictly more than 50% items should be successful.
15+
* ConsensusStrategy is a StrategyInterface implementation where strictly more than 50% items should be successful.
1816
*
1917
* @author Jérémy Derussé <jeremy@derusse.com>
2018
*/
21-
class ConsensusStrategy implements QuorumInterface
19+
class ConsensusStrategy implements StrategyInterface
2220
{
2321
/**
2422
* {@inheritdoc}

‎src/Symfony/Component/Lock/QuorumInterface.php renamed to ‎src/Symfony/Component/Lock/Strategy/StrategyInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Strategy/StrategyInterface.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Lock;
12+
namespace Symfony\Component\Lock\Strategy;
1313

1414
/**
15-
* QuorumInterface defines an interface to indicate when a quorum is met and can be met.
15+
* StrategyInterface defines an interface to indicate when a quorum is met and can be met.
1616
*
1717
* @author Jérémy Derussé <jeremy@derusse.com>
1818
*/
19-
interface QuorumInterface
19+
interface StrategyInterface
2020
{
2121
/**
2222
* Returns whether or not the quorum is met.

‎src/Symfony/Component/Lock/Quorum/UnanimousStrategy.php renamed to ‎src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Lock\Quorum;
13-
14-
use Symfony\Component\Lock\QuorumInterface;
12+
namespace Symfony\Component\Lock\Strategy;
1513

1614
/**
17-
* UnanimousStrategy is a QuorumInterface implementation where 100% of elements should be successful.
15+
* UnanimousStrategy is a StrategyInterface implementation where 100% of elements should be successful.
1816
*
1917
* @author Jérémy Derussé <jeremy@derusse.com>
2018
*/
21-
class UnanimousStrategy implements QuorumInterface
19+
class UnanimousStrategy implements StrategyInterface
2220
{
2321
/**
2422
* {@inheritdoc}

‎src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
+27-27Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use Symfony\Component\Lock\Exception\LockConflictedException;
1515
use Symfony\Component\Lock\Key;
16-
use Symfony\Component\Lock\Quorum\UnanimousStrategy;
17-
use Symfony\Component\Lock\QuorumInterface;
16+
use Symfony\Component\Lock\Strategy\UnanimousStrategy;
17+
use Symfony\Component\Lock\Strategy\StrategyInterface;
1818
use Symfony\Component\Lock\Store\CombinedStore;
1919
use Symfony\Component\Lock\Store\RedisStore;
2020
use Symfony\Component\Lock\StoreInterface;
@@ -50,7 +50,7 @@ public function getStore()
5050
}
5151

5252
/** @var \PHPUnit_Framework_MockObject_MockObject */
53-
private $quorum;
53+
private $strategy;
5454
/** @var \PHPUnit_Framework_MockObject_MockObject */
5555
private $store1;
5656
/** @var \PHPUnit_Framework_MockObject_MockObject */
@@ -60,11 +60,11 @@ public function getStore()
6060

6161
public function setup()
6262
{
63-
$this->quorum = $this->getMockBuilder(QuorumInterface::class)->getMock();
63+
$this->strategy = $this->getMockBuilder(StrategyInterface::class)->getMock();
6464
$this->store1 = $this->getMockBuilder(StoreInterface::class)->getMock();
6565
$this->store2 = $this->getMockBuilder(StoreInterface::class)->getMock();
6666

67-
$this->store = new CombinedStore(array($this->store1, $this->store2), $this->quorum);
67+
$this->store = new CombinedStore(array($this->store1, $this->store2), $this->strategy);
6868
}
6969

7070
/**
@@ -85,11 +85,11 @@ public function testSaveThrowsExceptionOnFailure()
8585
->with($key)
8686
->willThrowException(new LockConflictedException());
8787

88-
$this->quorum
88+
$this->strategy
8989
->expects($this->any())
9090
->method('canBeMet')
9191
->willReturn(true);
92-
$this->quorum
92+
$this->strategy
9393
->expects($this->any())
9494
->method('isMet')
9595
->willReturn(false);
@@ -119,11 +119,11 @@ public function testSaveCleanupOnFailure()
119119
->expects($this->once())
120120
->method('delete');
121121

122-
$this->quorum
122+
$this->strategy
123123
->expects($this->any())
124124
->method('canBeMet')
125125
->willReturn(true);
126-
$this->quorum
126+
$this->strategy
127127
->expects($this->any())
128128
->method('isMet')
129129
->willReturn(false);
@@ -135,7 +135,7 @@ public function testSaveCleanupOnFailure()
135135
}
136136
}
137137

138-
public function testSaveAbortWhenQuorumCantBeMet()
138+
public function testSaveAbortWhenStrategyCantBeMet()
139139
{
140140
$key = new Key(uniqid(__METHOD__, true));
141141

@@ -148,11 +148,11 @@ public function testSaveAbortWhenQuorumCantBeMet()
148148
->expects($this->never())
149149
->method('save');
150150

151-
$this->quorum
151+
$this->strategy
152152
->expects($this->once())
153153
->method('canBeMet')
154154
->willReturn(false);
155-
$this->quorum
155+
$this->strategy
156156
->expects($this->any())
157157
->method('isMet')
158158
->willReturn(false);
@@ -183,11 +183,11 @@ public function testputOffExpirationThrowsExceptionOnFailure()
183183
->with($key, $ttl)
184184
->willThrowException(new LockConflictedException());
185185

186-
$this->quorum
186+
$this->strategy
187187
->expects($this->any())
188188
->method('canBeMet')
189189
->willReturn(true);
190-
$this->quorum
190+
$this->strategy
191191
->expects($this->any())
192192
->method('isMet')
193193
->willReturn(false);
@@ -218,11 +218,11 @@ public function testputOffExpirationCleanupOnFailure()
218218
->expects($this->once())
219219
->method('delete');
220220

221-
$this->quorum
221+
$this->strategy
222222
->expects($this->any())
223223
->method('canBeMet')
224224
->willReturn(true);
225-
$this->quorum
225+
$this->strategy
226226
->expects($this->any())
227227
->method('isMet')
228228
->willReturn(false);
@@ -234,7 +234,7 @@ public function testputOffExpirationCleanupOnFailure()
234234
}
235235
}
236236

237-
public function testputOffExpirationAbortWhenQuorumCantBeMet()
237+
public function testputOffExpirationAbortWhenStrategyCantBeMet()
238238
{
239239
$key = new Key(uniqid(__METHOD__, true));
240240
$ttl = random_int(1, 10);
@@ -248,11 +248,11 @@ public function testputOffExpirationAbortWhenQuorumCantBeMet()
248248
->expects($this->never())
249249
->method('putOffExpiration');
250250

251-
$this->quorum
251+
$this->strategy
252252
->expects($this->once())
253253
->method('canBeMet')
254254
->willReturn(false);
255-
$this->quorum
255+
$this->strategy
256256
->expects($this->any())
257257
->method('isMet')
258258
->willReturn(false);
@@ -269,16 +269,16 @@ public function testPutOffExpirationIgnoreNonExpiringStorage()
269269
$store1 = $this->getMockBuilder(StoreInterface::class)->getMock();
270270
$store2 = $this->getMockBuilder(StoreInterface::class)->getMock();
271271

272-
$store = new CombinedStore(array($store1, $store2), $this->quorum);
272+
$store = new CombinedStore(array($store1, $store2), $this->strategy);
273273

274274
$key = new Key(uniqid(__METHOD__, true));
275275
$ttl = random_int(1, 10);
276276

277-
$this->quorum
277+
$this->strategy
278278
->expects($this->any())
279279
->method('canBeMet')
280280
->willReturn(true);
281-
$this->quorum
281+
$this->strategy
282282
->expects($this->once())
283283
->method('isMet')
284284
->with(2, 2)
@@ -300,19 +300,19 @@ public function testExistsDontAskToEveryBody()
300300
->expects($this->never())
301301
->method('exists');
302302

303-
$this->quorum
303+
$this->strategy
304304
->expects($this->any())
305305
->method('canBeMet')
306306
->willReturn(true);
307-
$this->quorum
307+
$this->strategy
308308
->expects($this->once())
309309
->method('isMet')
310310
->willReturn(true);
311311

312312
$this->assertTrue($this->store->exists($key));
313313
}
314314

315-
public function testExistsAbortWhenQuorumCantBeMet()
315+
public function testExistsAbortWhenStrategyCantBeMet()
316316
{
317317
$key = new Key(uniqid(__METHOD__, true));
318318

@@ -325,11 +325,11 @@ public function testExistsAbortWhenQuorumCantBeMet()
325325
->expects($this->never())
326326
->method('exists');
327327

328-
$this->quorum
328+
$this->strategy
329329
->expects($this->once())
330330
->method('canBeMet')
331331
->willReturn(false);
332-
$this->quorum
332+
$this->strategy
333333
->expects($this->once())
334334
->method('isMet')
335335
->willReturn(false);

‎src/Symfony/Component/Lock/Tests/Quorum/ConsensusStrategyTest.php renamed to ‎src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Tests/Strategy/ConsensusStrategyTest.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Lock\Tests\Quorum;
12+
namespace Symfony\Component\Lock\Tests\Strategy;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Lock\Quorum\ConsensusStrategy;
15+
use Symfony\Component\Lock\Strategy\ConsensusStrategy;
1616

1717
/**
1818
* @author Jérémy Derussé <jeremy@derusse.com>
1919
*/
2020
class ConsensusStrategyTest extends TestCase
2121
{
2222
/** @var ConsensusStrategy */
23-
private $quorum;
23+
private $strategy;
2424

2525
public function setup()
2626
{
27-
$this->quorum = new ConsensusStrategy();
27+
$this->strategy = new ConsensusStrategy();
2828
}
2929

3030
public function provideMetResults()
@@ -76,14 +76,14 @@ public function provideIndeterminate()
7676
*/
7777
public function testMet($success, $failure, $total, $isMet)
7878
{
79-
$this->assertSame($isMet, $this->quorum->isMet($success, $total));
79+
$this->assertSame($isMet, $this->strategy->isMet($success, $total));
8080
}
8181

8282
/**
8383
* @dataProvider provideIndeterminate
8484
*/
8585
public function canBeMet($success, $failure, $total, $isMet)
8686
{
87-
$this->assertSame($isMet, $this->quorum->canBeMet($failure, $total));
87+
$this->assertSame($isMet, $this->strategy->canBeMet($failure, $total));
8888
}
8989
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.