Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit 693f92e

Browse files
authored
Merge pull request #14 from spiral/feature/method-deprecation
Mark Broadcast::isAvailable method as deprecated.
2 parents 86470ad + fb31bbf commit 693f92e

File tree

4 files changed

+5
-48
lines changed

4 files changed

+5
-48
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ require __DIR__ . '/vendor/autoload.php';
6666

6767
$broadcast = new Broadcast(RPC::create('tcp://127.0.0.1:6001'));
6868

69-
if (!$broadcast->isAvailable()) {
70-
throw new \LogicException('The [broadcast] plugin not available');
71-
}
72-
7369
//
7470
// Now we can send a message to a specific topic
7571
//

src/Broadcast.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,11 @@ public function __construct(RPCInterface $rpc)
3838
}
3939

4040
/**
41-
* {@inheritDoc}
41+
* @deprecated Information about RoadRunner plugins is not available since RoadRunner version 2.2
4242
*/
4343
public function isAvailable(): bool
4444
{
45-
try {
46-
/** @var array<string>|mixed $result */
47-
$result = $this->rpc
48-
->withCodec(new JsonCodec())
49-
->call('informer.List', true);
50-
51-
if (! \is_array($result)) {
52-
return false;
53-
}
54-
55-
return \in_array('websockets', $result, true);
56-
} catch (\Throwable $e) {
57-
return false;
58-
}
45+
throw new \RuntimeException(\sprintf('%s::isAvailable method is deprecated.', self::class));
5946
}
6047

6148
/**

src/BroadcastInterface.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
*/
2121
interface BroadcastInterface
2222
{
23-
/**
24-
* Returns information about whether a broadcast plugin is available.
25-
*
26-
* @return bool
27-
*/
28-
public function isAvailable(): bool;
29-
3023
/**
3124
* Method to send messages to the required topic (channel).
3225
* <code>

tests/BroadcastTestCase.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,10 @@ public function testFactoryCreation(): void
3737

3838
public function testIsAvailable(): void
3939
{
40-
$factory = $this->broadcast(['informer.List' => '["websockets"]']);
41-
$this->assertTrue($factory->isAvailable());
42-
}
43-
44-
public function testNotAvailable(): void
45-
{
46-
$factory = $this->broadcast(['informer.List' => '[]']);
47-
$this->assertFalse($factory->isAvailable());
48-
}
49-
50-
public function testNotAvailableOnNonArrayResponse(): void
51-
{
52-
$factory = $this->broadcast(['informer.List' => '42']);
53-
$this->assertFalse($factory->isAvailable());
54-
}
55-
56-
public function testNotAvailableOnErrorResponse(): void
57-
{
58-
$factory = $this->broadcast(['informer.List' => (static function () {
59-
throw new \Exception();
60-
})]);
40+
$this->expectException(\RuntimeException::class);
41+
$this->expectErrorMessage('Spiral\RoadRunner\Broadcast\Broadcast::isAvailable method is deprecated.');
6142

62-
$this->assertFalse($factory->isAvailable());
43+
$this->broadcast()->isAvailable();
6344
}
6445

6546
public function testPublishingSingleMessage(): void

0 commit comments

Comments
 (0)