Skip to content

Commit d2a53a5

Browse files
committed
install pecl redis on travis
1 parent dec46c3 commit d2a53a5

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ before_install:
128128

129129
install: travis_retry composer install --prefer-dist --no-interaction --no-suggest
130130

131-
before_script: SUPERVISE=no travis_retry ./start-cluster.sh || { cat ./cluster/*.log; false; }
131+
before_script:
132+
- sudo pecl install redis
133+
- echo "extension=redis.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
134+
- SUPERVISE=no travis_retry ./start-cluster.sh || { cat ./cluster/*.log; false; }
132135

133136
script: vendor/bin/phpunit --exclude-group ${LUMEN_VERSION:+laravel-only},${HORIZON:-horizon}

src/Connections/PhpRedisConnection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Monospice\LaravelRedisSentinel\Connections;
44

5-
use Monospice\LaravelRedisSentinel\Exceptions\RetryRedisException;
5+
use Monospice\LaravelRedisSentinel\Exceptions\RedisRetryException;
66
use Closure;
77
use Illuminate\Redis\Connections\PhpRedisConnection as LaravelPhpRedisConnection;
88
use Redis;
@@ -188,7 +188,7 @@ public function command($method, array $parameters = [])
188188
* @param callable $callback The operation to execute.
189189
* @return mixed The result of the first successful attempt.
190190
*
191-
* @throws RedisException After exhausting the allowed number of
191+
* @throws RedisRetryException After exhausting the allowed number of
192192
* attempts to reconnect.
193193
*/
194194
protected function retryOnFailure(callable $callback)
@@ -214,6 +214,6 @@ protected function retryOnFailure(callable $callback)
214214
}
215215
} while ($attempts < $this->retryLimit);
216216

217-
throw new RetryRedisException(sprintf('Reached the reconnect limit of %d attempts', $attempts));
217+
throw new RedisRetryException(sprintf('Reached the reconnect limit of %d attempts', $attempts));
218218
}
219219
}

src/Connectors/PhpRedisConnector.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@ private function updateSentinels(RedisSentinel $sentinel, string $currentHost, i
154154
'host' => $currentHost,
155155
'port' => $currentPort,
156156
]
157-
], array_map(fn ($sentinel) => [
158-
'host' => $sentinel['ip'],
159-
'port' => $sentinel['port'],
160-
], $sentinel->sentinels($service))
157+
], array_map(function ($sentinel) {
158+
return [
159+
'host' => $sentinel['ip'],
160+
'port' => $sentinel['port'],
161+
];
162+
}, $sentinel->sentinels($service))
161163
);
162164
}
163165

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use RedisException as PhpRedisException;
66

7-
class RetryRedisException extends PhpRedisException
7+
class RedisRetryException extends PhpRedisException
88
{
99
//
1010
}

tests/Integration/Connections/PhpRedisConnectionTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Monospice\LaravelRedisSentinel\Connectors\PhpRedisConnector;
88
use Monospice\LaravelRedisSentinel\Tests\Support\DummyException;
99
use Monospice\LaravelRedisSentinel\Tests\Support\IntegrationTestCase;
10-
use Monospice\LaravelRedisSentinel\Exceptions\RetryRedisException;
10+
use Monospice\LaravelRedisSentinel\Exceptions\RedisRetryException;
1111
use Redis;
1212
use RedisException;
1313

@@ -95,11 +95,9 @@ public function testAbortsTransactionOnException()
9595

9696
public function testRetriesTransactionWhenConnectionFails()
9797
{
98-
$this->expectException(RetryRedisException::class);
98+
$this->expectException(RedisRetryException::class);
9999

100-
$expectedRetries = 2;
101-
102-
$this->subject = $this->makeConnection($expectedRetries, 0); // retry immediately
100+
$this->subject = $this->makeConnection(1, 0); // retry once and immediately
103101

104102
$this->subject->transaction(function () {
105103
throw new RedisException();

0 commit comments

Comments
 (0)