コード例 #1
0
ファイル: ThriftClient.php プロジェクト: pospon/ThriftBundle
 /**
  * Return client
  * @return Thrift\Transport\TSocket
  */
 public function getClient()
 {
     if (is_null($this->client)) {
         $service = $this->config['service_config'];
         //Initialisation du client
         $socket = $this->clientFactory()->getSocket();
         if (isset($service['transport'])) {
             $this->transport = new $service['transport']($socket);
         } else {
             $this->transport = new TBufferedTransport($socket, 1024, 1024);
         }
         $this->client = $this->factory->getClientInstance($this->config['service'], new $service['protocol']($this->transport));
         $this->transport->open();
     }
     return $this->client;
 }
コード例 #2
0
 public function testFactory()
 {
     $factory = new ThriftFactory(array('test' => array('definition' => 'Test', 'className' => 'TestService', 'namespace' => 'ThriftModel\\Test')));
     $this->assertInstanceOf('ThriftModel\\Test\\Test', $factory->getInstance('ThriftModel\\Test\\Test'));
     $this->assertInstanceOf('ThriftModel\\Test\\Test', $factory->getInstance('ThriftModel\\Test\\Test', array()));
     $this->assertInstanceOf('ThriftModel\\Test\\State', $factory->getInstance('ThriftModel\\Test\\State'));
     $this->assertInstanceOf('ThriftModel\\Test\\InvalidValueException', $factory->getInstance('ThriftModel\\Test\\InvalidValueException'));
     $this->assertInstanceOf('ThriftModel\\Test\\TestServiceProcessor', $factory->getProcessorInstance('test', null));
     $this->assertInstanceOf('ThriftModel\\Test\\TestServiceClient', $factory->getClientInstance('test', null));
 }