-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDRPC.php
54 lines (34 loc) · 1023 Bytes
/
DRPC.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
Class DRPC {
var $hostName;
var $portNo;
var $timeout;
var $socket;
var $transport;
var $protocol;
var $drpcClient;
function __construct($hostName,$portNo,$timeout) {
$this->hostName = $hostName;
$this->portNo = $portNo;
$this->timeout = $timeout;
try {
$this->socket = new Thrift\Transport\TSocket($hostName, $portNo);
if($timeout!=null) {
$this->socket->setSendTimeout($timeout);
$this->socket->setRecvTimeout($timeout);
}
$this->transport = new Thrift\Transport\TFramedTransport($this->socket);
$this->drpcClient = new DistributedRPCClient(new Thrift\Protocol\TBinaryProtocol($this->transport));
} catch (Exception $tx) {
echo $tx->xdebug_message;
print 'TException: '.$tx->why. ' Error: '.$tx->getMessage() . "\n";
}
}
function execute($func,$params) {
$this->transport->open();
$result = $this->drpcClient->execute($func,$params);
$this->transport->close();
return $result;
}
}
?>