Skip to content

Commit

Permalink
support cluster resources classify
Browse files Browse the repository at this point in the history
  • Loading branch information
moolex committed Nov 23, 2018
1 parent 0bdbb4c commit 84b23cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Cluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

namespace Carno\Redis;

use Carno\Cluster\Classify\Scenes;
use Carno\Cluster\Contracts\Tags;
use Carno\Cluster\Managed;
use Carno\Cluster\Resources;
Expand Down Expand Up @@ -52,7 +53,7 @@ abstract class Cluster extends Managed
*/
public function __construct(Resources $resources)
{
$resources->initialize($this->type, $this->server, $this);
$resources->initialize(Scenes::RESOURCE, $this->type, $this->server, $this);
}

/**
Expand All @@ -72,7 +73,7 @@ protected function connecting(Endpoint $endpoint) : Pool
$vid = "{$this->type}:{$this->server}";

$dsn = new DSN(
$node->port() === 0
$node->port() <= 0
? $node->host()
: sprintf('redis://%s:%d', $node->host(), $node->port())
);
Expand Down
7 changes: 5 additions & 2 deletions tests/ClusterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

namespace Carno\Redis\Tests;

use Carno\Cluster\Discover\Adaptors\DNS;
use Carno\Cluster\Classify\Scenes;
use Carno\Cluster\Classify\Selector;
use Carno\Cluster\Discovery\Adaptors\DNS;
use Carno\Cluster\Resources;
use function Carno\Coroutine\async;
use Carno\Net\Endpoint;
Expand All @@ -26,7 +28,8 @@ class ClusterTest extends TestCase

private function cluster()
{
return $this->cluster ?? $this->cluster = new Resources(new DNS);
($s = new Selector)->assigning(Scenes::RESOURCE, new DNS);
return $this->cluster ?? $this->cluster = new Resources($s);
}

private function redis()
Expand Down

0 comments on commit 84b23cb

Please sign in to comment.