Exemple #1
0
 /**
  * @expectedException \Exception
  */
 public function testMuxNoRoutingKey()
 {
     // given
     $coll = new Collective($this->driver, $this->mapper, $this->routing);
     $coll->assimilate($this);
     $args = ["hello world", new Chan(null, $this->driver, $this->mapper), new Foo("bar")];
     $req2 = $this->buildRequest($args);
     $req = new Request();
     $req->setBody($req2->getBody());
     // when
     $resp = $coll->mux($req);
 }
Exemple #2
0
 public function marshalRoutineRequest(RoutineRequest $req)
 {
     $type = $req->getType();
     $method = $req->getMethod();
     $vos = $this->marshalForMethod($req->getArgs(), $req->getType(), $req->getMethod());
     $vos[] = $this->marshalArg($req->getExitChan(), Chan::CLASSNAME);
     $vos[] = $req->getRetryErrors();
     $topicStr = $this->marshalTopicString($req->getNs(), $req->getDc(), $req->getType(), $req->getMethod());
     $r = new Request();
     $r->addHeader('X-routing-key', $topicStr);
     $r->setBody(json_encode($vos));
     return $r;
 }
Exemple #3
0
 public function createDefault()
 {
     $inst = new Request();
     $inst->setProtocol(self::getProtocol());
     $inst->setHost(self::getHost());
     $inst->setUrl(self::getCurrentUrl());
     $inst->setHttpMethod(self::getHttpMethod());
     $inst->setBody(self::getBody());
     $inst->setGetParams(self::getGetParams());
     $headers = self::getRequestHeaders();
     foreach ($headers as $key => $val) {
         $inst->addHeader($key, $val);
     }
     return $inst;
 }
Exemple #4
0
 public function testTopicFromString()
 {
     // given
     $x = $this->buildRequest('', '', 'Fliglio\\Borg\\TopicTest', 'testTopic');
     $x2 = $this->mapper->marshalRoutineRequest($x);
     $req = new Request();
     $req->addHeader("X-routing-key", 'foo.bar.Fliglio.Borg.TopicTest.testTopic');
     $req->setBody($x2->getBody());
     // when
     $found = $this->mapper->unmarshalRoutineRequest($req);
     // then
     $this->assertEquals('foo', $found->getNs(), 'should match');
     $this->assertEquals('bar', $found->getDc(), 'should match');
     $this->assertEquals('Fliglio\\Borg\\TopicTest', $found->getType(), 'should match');
     $this->assertEquals('testTopic', $found->getMethod(), 'should match');
 }