public static function LOAD_CLASSES($libPath) { require_once $libPath . '/Thrift/ClassLoader/ThriftClassLoader.php'; $cl = new \Thrift\ClassLoader\ThriftClassLoader(false); $cl->registerNamespace('Thrift', $libPath); $cl->register(true); require_once $libPath . '/P13nService.php'; require_once $libPath . '/Types.php'; require_once $libPath . "/BxFacets.php"; require_once $libPath . "/BxFilter.php"; require_once $libPath . "/BxRequest.php"; require_once $libPath . "/BxRecommendationRequest.php"; require_once $libPath . "/BxSearchRequest.php"; require_once $libPath . "/BxAutocompleteRequest.php"; require_once $libPath . "/BxSortFields.php"; require_once $libPath . "/BxChooseResponse.php"; require_once $libPath . "/BxAutocompleteResponse.php"; require_once $libPath . "/BxData.php"; }
function rpcserver_call(swoole_process $worker) { define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application"); define('THRIFT_DIR_PATH', dirname(APPLICATION_PATH) . "/thrift"); require_once THRIFT_DIR_PATH . "/Thrift/ClassLoader/ThriftClassLoader.php"; $loader = new Thrift\ClassLoader\ThriftClassLoader(); $loader->registerNamespace('Thrift', THRIFT_DIR_PATH); $loader->registerNamespace('swoole', THRIFT_DIR_PATH); $loader->registerNamespace('Bin', THRIFT_DIR_PATH); $loader->registerDefinition('Bin', THRIFT_DIR_PATH); $loader->register(); define('MYPATH', dirname(APPLICATION_PATH)); $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini"); $application->bootstrap(); $config_obj = Yaf_Registry::get("config"); $rpc_config = $config_obj->rpc->toArray(); define('SERVERIP', $rpc_config['ServerIp']); define('SERVERPORT', $rpc_config['port']); define('SERVERHOST', $rpc_config['host']); $service = new Bin\rpc\Handler(); $processor = new Bin\rpc\rpcProcessor($service); $socket_tranport = new Thrift\Server\TServerSocket(SERVERIP, SERVERPORT); $out_factory = $in_factory = new Thrift\Factory\TFramedTransportFactory(); $out_protocol = $in_protocol = new Thrift\Factory\TBinaryProtocolFactory(); $server = new swoole\RpcServer($processor, $socket_tranport, $in_factory, $out_factory, $in_protocol, $out_protocol); $server->serve(); }
public function __construct() { $rpc_dir = dirname(dirname(__DIR__)) . "/thrift"; $yaf_load = Yaf_Loader::getInstance(); $yaf_load->setLibraryPath($rpc_dir, true); require_once $rpc_dir . "/Thrift/ClassLoader/ThriftClassLoader.php"; $loader = new Thrift\ClassLoader\ThriftClassLoader(); $loader->registerNamespace('Thrift', $rpc_dir); $loader->registerNamespace('swoole', $rpc_dir); $loader->registerNamespace('Bin', $rpc_dir); $loader->registerDefinition('Bin', $rpc_dir); $loader->register(); $config_obj = Yaf_Registry::get("config"); $rpc_config = $config_obj->rpc->toArray(); $socket = new Thrift\Transport\TSocket($rpc_config['host'], $rpc_config['port']); $this->transport = new Thrift\Transport\TFramedTransport($socket); $protocol = new Thrift\Protocol\TBinaryProtocol($this->transport); $this->transport->open(); $this->client = new Bin\rpc\rpcClient($protocol); //$yaf_load->setLibraryPath(dirname($rpc_dir).'/library',true); }
<?php define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application"); define('THRIFT_DIR_PATH', dirname(APPLICATION_PATH) . "/thrift"); require_once THRIFT_DIR_PATH . "/Thrift/ClassLoader/ThriftClassLoader.php"; $loader = new Thrift\ClassLoader\ThriftClassLoader(); $loader->registerNamespace('Thrift', THRIFT_DIR_PATH); $loader->registerNamespace('swoole', THRIFT_DIR_PATH); $loader->registerNamespace('Bin', THRIFT_DIR_PATH); $loader->registerDefinition('Bin', THRIFT_DIR_PATH); $loader->register(); $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini"); $application->bootstrap(); $config_obj = Yaf_Registry::get("config"); $rpc_config = $config_obj->rpc->toArray(); define('SERVERIP', $rpc_config['ServerIp']); define('SERVERPORT', $rpc_config['port']); define('SERVERHOST', $rpc_config['host']); $service = new Bin\rpc\Handler(); $processor = new Bin\rpc\rpcProcessor($service); $socket_tranport = new Thrift\Server\TServerSocket(SERVERIP, SERVERPORT); $out_factory = $in_factory = new Thrift\Factory\TFramedTransportFactory(); $out_protocol = $in_protocol = new Thrift\Factory\TBinaryProtocolFactory(); $server = new swoole\Server($processor, $socket_tranport, $in_factory, $out_factory, $in_protocol, $out_protocol); $server->serve();
* * Licensed under The MIT License * For full copyright and license information, please see the MIT-LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @author walkor<*****@*****.**> * @copyright walkor<*****@*****.**> * @link http://www.workerman.net/ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ namespace ThriftClient; define('THRIFT_CLIENT', realpath(__DIR__)); require_once THRIFT_CLIENT . '/../Lib/Thrift/ClassLoader/ThriftClassLoader.php'; require_once THRIFT_CLIENT . '/AddressManager.php'; $loader = new \Thrift\ClassLoader\ThriftClassLoader(); $loader->registerNamespace('Thrift', THRIFT_CLIENT . '/../Lib'); $loader->register(); /** * * 通用客户端,支持故障ip自动踢出及探测节点是否已经存活 * * <b>使用示例:</b> * <pre> * <code> // 引入客户端文件 require_once 'yourdir/workerman/applications/ThriftRpc/Clients/ThriftClient.php'; use ThriftClient; // 传入配置,一般在某统一入口文件中调用一次该配置接口即可 ThriftClient::config(array(
* /usr/bin/php updateReputationList.php list * * ATTENTION: This PHP script must run in CLI! * * If you have any problems, let us know! * See how to get help at http://ids-hogzilla.org/post/community/ */ // Some useful variables $hbaseHost = "localhost"; /* Host or IP of your HBase */ $hbasePort = 9090; $GLOBALS['THRIFT_ROOT'] = '/usr/share/php'; define("DEBUG", true); // Thrift stuff require_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/ClassLoader/ThriftClassLoader.php'; $classLoader = new Thrift\ClassLoader\ThriftClassLoader(); $classLoader->registerNamespace('Thrift', $GLOBALS['THRIFT_ROOT']); $classLoader->register(); require_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Transport/TSocket.php'; require_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Transport/TBufferedTransport.php'; require_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Protocol/TBinaryProtocol.php'; require_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Packages/Hbase/Hbase.php'; require_once $GLOBALS['THRIFT_ROOT'] . '/Thrift/Packages/Hbase/Types.php'; $socket = new Thrift\Transport\TSocket($hbaseHost, $hbasePort); $socket->setSendTimeout(10000); $socket->setRecvTimeout(20000); $transport = new Thrift\Transport\TBufferedTransport($socket); $protocol = new Thrift\Protocol\TBinaryProtocol($transport); $client = new Hbase\HbaseClient($protocol); /* * BEGIN