pbgo基于 Protobuf 的 RPC/REST 迷你框架
pbgo 基于 Protobuf 定义接口规范,通过pbgo提供的插件生成RPC和REST相关代码。
创建hello.proto文件,定义接口规范:
syntax = "proto3"; package hello_pb; import "github.com/chai2010/pbgo/pbgo.proto"; message String { string value = 1; } service EchoService { rpc Echo (String) returns (String) { option (pbgo.rest_api) = { get: "/echo/:value" }; } }
用pbgo插件生成代码:
$ protoc -I=. -I=$(GOPATH)/src --pbgo_out=. hello.proto
创建REST服务:
type EchoService struct{} func (p *EchoService) Echo(request *hello_pb.String, reply *hello_pb.String) error { *reply = *request return nil } func main() { router := hello_pb.EchoServiceHandler(new(EchoService)) log.Fatal(http.ListenAndServe(":8080", router)) }
测试REST服务:
$ curl localhost:8080/echo/gopher {"value":"gopher"} $ curl localhost:8080/echo/gopher?value=cgo {"value":"cgo"}
详细的例子请参考:https://github.com/chai2010/pbgo/blob/master/examples/hello.p
评论
simple-rpc基于 netty 的 RPC 框架
simple-rpc 是一款基于 netty 的 RPC 框架,现有功能:基本的客户端、服务端交互提
simple-rpc基于 netty 的 RPC 框架
0
simple-rpc基于 netty 的 RPC 框架
simple-rpc是一款基于netty的RPC框架,现有功能:基本的客户端、服务端交互提供代理实现接口spring集成,xml配置和JavaConfig配置方式服务发布订阅DONE断线重连DONER
simple-rpc基于 netty 的 RPC 框架
0
Fast RPC基于FastCGI通讯协议的RPC框架
fastRPC 是基于FastCGI通讯协议的RPC框架,它适用多人合作开发的高并发网站项目。通过这
Fast RPC基于FastCGI通讯协议的RPC框架
0
Fast RPC基于FastCGI通讯协议的RPC框架
fastRPC是基于FastCGI通讯协议的RPC框架,它适用多人合作开发的高并发网站项目。通过这个RPC框架,可以将MVC思想中的Model后置于RPCServer层转型为服务,以协议方式暴露Mod
Fast RPC基于FastCGI通讯协议的RPC框架
0