Example #1
0
<?php

require_once 'bootstrap.php';
use Thrift\Transport\TSocketPool;
use Thrift\Transport\TBufferedTransport;
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Exception\TTransportException;
use Thrift\Exception\TProtocolException;
use fun\rpc\FunServantClient;
use fun\rpc\Context;
use fun\rpc\TCacheMissed;
use fun\rpc\TMongoMissed;
use fun\rpc\TMemcacheData;
try {
    $sock = new TSocketPool(array('localhost'), array(9001));
    $sock->setDebug(0);
    $sock->setSendTimeout(4000);
    $sock->setRecvTimeout(4000);
    $sock->setNumRetries(1);
    $transport = new TBufferedTransport($sock, 1024, 1024);
    $protocol = new TBinaryProtocol($transport);
    // get our client
    $client = new FunServantClient($protocol);
    $transport->open();
    $ctx = new Context(array('reason' => "phptest", 'rid' => hexdec(uniqid())));
    // ping
    $return = $client->ping($ctx);
    echo "[Client] ping received: ", $return, "\n";
    // id.next
    echo "[Client] id_next received:", $client->id_next($ctx), "\n";
    echo "[Client] id_next received:", $client->id_next($ctx), "\n";
Example #2
0
if ($argc > 2) {
    $host = $argv[1];
}
foreach ($argv as $arg) {
    if (substr($arg, 0, 7) == '--port=') {
        $port = substr($arg, 7);
    } else {
        if (substr($arg, 0, 11) == '--transport=') {
            $MODE = substr($arg, 11);
        }
    }
}
$hosts = array('localhost');
$socket = new TSocket($host, $port);
$socket = new TSocketPool($hosts, $port);
$socket->setDebug(TRUE);
if ($MODE == 'inline') {
    $transport = $socket;
    $testClient = new \ThriftTest\ThriftTestClient($transport);
} else {
    if ($MODE == 'framed') {
        $framedSocket = new TFramedTransport($socket);
        $transport = $framedSocket;
        $protocol = new TBinaryProtocol($transport);
        $testClient = new \ThriftTest\ThriftTestClient($protocol);
    } else {
        $bufferedSocket = new TBufferedTransport($socket, 1024, 1024);
        $transport = $bufferedSocket;
        $protocol = new TBinaryProtocol($transport);
        $testClient = new \ThriftTest\ThriftTestClient($protocol);
    }
Example #3
0
<?php

require_once 'bootstrap.php';
use Thrift\Transport\TSocketPool;
use Thrift\Transport\TBufferedTransport;
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Exception\TTransportException;
use Thrift\Exception\TProtocolException;
use fun\rpc\FunServantClient;
use fun\rpc\Context;
use fun\rpc\TCacheMissed;
use fun\rpc\TMongoMissed;
use fun\rpc\TMemcacheData;
try {
    $sock = new TSocketPool(array('localhost', 'localhost'), array(9001, 9011));
    $sock->setDebug(1);
    $sock->setSendTimeout(4000);
    $sock->setRecvTimeout(4000);
    $sock->setNumRetries(1);
    $transport = new TBufferedTransport($sock, 1024, 1024);
    $protocol = new TBinaryProtocol($transport);
    // get our client
    $client = new FunServantClient($protocol);
    $transport->open();
    $ctx = new Context(array('rid' => hexdec(uniqid()), 'reason' => 'call.init.121'));
    // mysql select multiple rows
    echo "\nDEMO SELECT\n";
    echo "===============================\n";
    $rows = $client->my_query($ctx, 'UserShard', 'UserInfo', 1, 'SELECT * from UserInfo where uid>?', array(1), '');
    echo $rows->rowsAffected, ':rowsAffected, ', $rows->lastInsertId, ':lastInsertId, rows:', PHP_EOL;
    print_r($rows);