13 Star 49 Fork 2

Gitee 极速下载/go-micro

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/micro/go-micro
克隆/下载
rpc_request.go 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
Asim Aslam 提交于 2019-01-18 10:12 . For the legacy
package server
import (
"github.com/micro/go-micro/codec"
"github.com/micro/go-micro/transport"
)
type rpcRequest struct {
service string
method string
endpoint string
contentType string
socket transport.Socket
codec codec.Codec
header map[string]string
body []byte
stream bool
}
type rpcMessage struct {
topic string
contentType string
payload interface{}
}
func (r *rpcRequest) Codec() codec.Reader {
return r.codec
}
func (r *rpcRequest) ContentType() string {
return r.contentType
}
func (r *rpcRequest) Service() string {
return r.service
}
func (r *rpcRequest) Method() string {
return r.method
}
func (r *rpcRequest) Endpoint() string {
return r.endpoint
}
func (r *rpcRequest) Header() map[string]string {
return r.header
}
func (r *rpcRequest) Read() ([]byte, error) {
// got a body
if r.body != nil {
b := r.body
r.body = nil
return b, nil
}
var msg transport.Message
err := r.socket.Recv(&msg)
if err != nil {
return nil, err
}
r.header = msg.Header
return msg.Body, nil
}
func (r *rpcRequest) Stream() bool {
return r.stream
}
func (r *rpcMessage) ContentType() string {
return r.contentType
}
func (r *rpcMessage) Topic() string {
return r.topic
}
func (r *rpcMessage) Payload() interface{} {
return r.payload
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mirrors/go-micro.git
git@gitee.com:mirrors/go-micro.git
mirrors
go-micro
go-micro
v0.22.0

搜索帮助