代码拉取完成,页面将自动刷新
composer create-project limingxinleo/thrift-go-phalcon-project
ln -s /your/path/to/thrift-go-phalcon-project/vendor/apache/thrift/lib/go/thrift thrift
从GO官网下载编译好的压缩包 例如 go1.8.3.linux-amd64.tar.gz
$ tar -xzf go1.8.3.linux-amd64.tar.gz
$ mv go /usr/local/go/1.8.3
$ vim /etc/profile
export GOROOT='/usr/local/go/1.8.3' # 没有文件夹则新建
export GOPATH='/usr/local/go/libs/' # 没有文件夹则新建
export PATH=$GOROOT/bin:$PATH
$ go get -u github.com/kardianos/govendor
$ cd /usr/local/go/libs/src/github.com/kardianos/govendor/
$ go build
$ cd /usr/local/bin
$ ln -s /usr/local/go/libs/src/github.com/kardianos/govendor/govendor govendor
# RPC服务注册方法
server.RegisterProcessor("app", service.NewAppProcessor(&impl.App{}));
$handler = new AppHandler();
$processor->registerProcessor('app', new AppProcessor($handler));
<?php
namespace App\Thrift\Services;
use MicroService\AppIf;
class AppHandler extends Handler implements AppIf
{
public function version()
{
return $this->config->version;
}
}
protected function beforeServerStart(swoole_server $server)
{
parent::beforeServerStart($server); // TODO: Change the autogenerated stub
// 增加服务注册心跳进程
$worker = new swoole_process(function (swoole_process $worker) {
$client = new swoole_client(SWOOLE_SOCK_TCP);
if (!$client->connect(env('REGISTRY_IP'), env('REGISTRY_PORT'), -1)) {
exit("connect failed. Error: {$client->errCode}\n");
}
swoole_timer_tick(5000, function () use ($client) {
$service = env('REGISTRY_SERVICE', 'github');
$data = [
'service' => $service,
'ip' => env('SERVICE_IP'),
'port' => env('SERVICE_PORT'),
'nonce' => time(),
'register' => true,
'sign' => 'xxx',
];
$client->send(json_encode($data));
$result = $client->recv();
$result = json_decode($result, true);
if ($result['success']) {
foreach ($result['services'] as $key => $item) {
Redis::hset($service, $key, json_encode($item));
}
}
});
});
$server->addProcess($worker);
}
bool(boolean): 布尔类型(TRUE or FALSE)
byte(byte): 8位带符号整数
i16(short): 16位带符号整数
i32(int): 32位带符号整数
i64(long): 64位带符号整数
double(double): 64位浮点数
string(String): 采用UTF-8编码的字符串
binary(ByteBuffer):未经过编码的字节流
struct UserProfile {
1: i32 uid,
2: string name,
3: string blurb
}
struct UserProfile {
1: i32 uid = 1,
2: string name = "User1",
3: string blurb
}
list(java.util.ArrayList) set(java.util.HashSet) map(java.util.HashMap)
struct Node {
1: i32 id,
2: string name,
3: list<i32> subNodeList,
4: map<i32,string> subNodeMap,
5: set<i32> subNodeSet
}
struct SubNode {
1: i32 uid,
2: string name,
3: i32 pid
}
struct Node {
1: i32 uid,
2: string name,
3: list<subNode> subNodes
}
service UserStorage {
void store(1: UserProfile user),
UserProfile retrieve(1: i32 uid)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型