Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fliglio/borg into 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Schwartz committed Jun 18, 2020
2 parents 4e4d700 + 3fcbf11 commit 932d577
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
7 changes: 2 additions & 5 deletions src/main/Fliglio/Borg/Amqp/AmqpCollectiveDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace Fliglio\Borg\Amqp;

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

use Fliglio\Borg\Driver\CollectiveDriver;
use Fliglio\Borg\Chan;

use Fliglio\Http\RequestReader;
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

class AmqpCollectiveDriver implements CollectiveDriver {

Expand Down
29 changes: 29 additions & 0 deletions src/main/Fliglio/Borg/AmqpCollectiveFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php


namespace Fliglio\Borg;


use Fliglio\Borg\Amqp\AmqpCollectiveDriver;
use Fliglio\Borg\Mapper\DefaultMapper;
use PhpAmqpLib\Connection\AMQPStreamConnection;

class AmqpCollectiveFactory {

private $rabbitConnection;
private $routingNamespace;

public function __construct(AMQPStreamConnection $rabbitConnection, $routingNamespace) {
$this->rabbitConnection = $rabbitConnection;
$this->routingNamespace = $routingNamespace;
}

public function create() {
$driver = new AmqpCollectiveDriver($this->rabbitConnection);
$mapper = new DefaultMapper($driver);
$routing = new RoutingConfiguration($this->routingNamespace);

return new Collective($driver, $mapper, $routing);
}
}

1 change: 1 addition & 0 deletions src/main/Fliglio/Borg/Collective.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function getMasterRoutingKey() {
public function assimilate($i) {
$i->setCollective($this);
$this->drones[get_class($i)] = $i;
return $this;
}

public function mkchan($type = null) {
Expand Down
16 changes: 7 additions & 9 deletions src/test/Fliglio/Borg/TestConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ class TestConfiguration extends DefaultConfiguration {

public function getRoutes() {
$rConn = new AMQPStreamConnection('localhost', 5672, "guest", "guest", "/");
$driver = new AmqpCollectiveDriver($rConn);


$resource = new TestResource();
$fun = new FunResource;
$shake = new ShakespeareResource;

$mapper = new DefaultMapper($driver);
$routing = new RoutingConfiguration("borg-demo");
$coll = new Collective($driver, $mapper, $routing);
$coll->assimilate($resource);
$coll->assimilate($fun);
$coll->assimilate($shake);

$coll = (new AmqpCollectiveFactory($rConn, "borg-demo"))
->create()
->assimilate($resource)
->assimilate($fun)
->assimilate($shake);



Expand Down
1 change: 1 addition & 0 deletions src/test/component/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function setup() {
$this->add = sprintf("http://%s:%s", getenv('LOCALDEV_PORT_80_TCP_ADDR'), 80);
}


public function testRoundTrip() {
// given
$expected = 'hello world';
Expand Down

0 comments on commit 932d577

Please sign in to comment.