Skip to content

Commit

Permalink
Socket Connector as a Service
Browse files Browse the repository at this point in the history
  • Loading branch information
mbonneau committed Jul 4, 2019
1 parent 228439b commit d5b5fc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Voryx/ThruwayBundle/Client/ClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Psr\Log\NullLogger;
use React\Promise\Deferred;
use React\Socket\ConnectorInterface;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Serializer\Serializer;
use Thruway\ClientSession;
Expand All @@ -27,16 +28,20 @@ class ClientManager

/** @var Serializer */
private $serializer;

/** @var ConnectorInterface */
private $connector;

/**
* @param Container $container
* @param $config
*/
public function __construct(Container $container, $config, Serializer $serializer)
public function __construct(Container $container, $config, Serializer $serializer, ConnectorInterface $connector)
{
$this->container = $container;
$this->config = $config;
$this->serializer = $serializer;
$this->connector = $connector;
}

/**
Expand Down Expand Up @@ -147,7 +152,7 @@ private function getShortClient()
{
$client = new Client($this->config['realm']);
$client->setAttemptRetry(false);
$client->addTransportProvider(new PawlTransportProvider($this->config['trusted_url']));
$client->addTransportProvider(new PawlTransportProvider($this->config['trusted_url'], $this->connector));

return $client;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Voryx/ThruwayBundle/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
<argument type="service" id="service_container"/>
<argument>%voryx_thruway%</argument>
<argument type="service" id="serializer"/>
<argument type="service" id="voryx.thruway.client.react_connector"/>
</service>

<service id="voryx.thruway.topic_state_handler" class="Voryx\ThruwayBundle\TopicStateHandler">
Expand Down Expand Up @@ -160,5 +161,10 @@
<tag name="console.command" command="thruway:worker:start" />
</service>

<service id="voryx.thruway.client.react_connector"
class="React\Socket\Connector"
>
<argument type="service" id="voryx.thruway.loop"/>
</service>
</services>
</container>

0 comments on commit d5b5fc0

Please sign in to comment.