public class StargateRpcProtocol extends AbstractProtocol
| 构造器和说明 |
|---|
StargateRpcProtocol() |
| 限定符和类型 | 方法和说明 |
|---|---|
Object |
decode(io.netty.channel.ChannelHandlerContext ctx,
DynamicCompositeByteBuf in,
boolean isDecodingRequest)
客户端/服务端解析请求包成header+body buffer
|
Request |
decodeRequest(Object packet)
服务端反序列化rpc请求
|
Response |
decodeResponse(Object msg,
io.netty.channel.ChannelHandlerContext ctx)
客户端解码响应操作
PS:
BRPC 有且仅有当BRPC作为客户端时,使用FastFuture的LogId 作为线程绑定ID
|
io.netty.buffer.ByteBuf |
encodeRequest(Request request)
客户端序列化请求对象
|
io.netty.buffer.ByteBuf |
encodeResponse(Request request,
Response response)
服务端序列化返回结果。
|
void |
initEnv() |
afterResponseSent, beforeRequestSent, createRequest, createResponse, getRequest, getResponse, isCoexistence, returnChannelBeforeResponsepublic void initEnv()
public Object decode(io.netty.channel.ChannelHandlerContext ctx, DynamicCompositeByteBuf in, boolean isDecodingRequest) throws TooBigDataException, NotEnoughDataException, BadSchemaException
Protocolin - 输入byte bufTooBigDataException - body太大NotEnoughDataException - 可读长度不够,由于粘包拆包问题。BadSchemaException - header格式不对public io.netty.buffer.ByteBuf encodeRequest(Request request) throws Exception
Protocolrequest - 待发送给服务端的对象Exception - 序列化异常public Response decodeResponse(Object msg, io.netty.channel.ChannelHandlerContext ctx) throws Exception
msg - header & body的bufctx - netty channel contextException - 反序列化异常public Request decodeRequest(Object packet) throws BadSchemaException
Protocolpacket - header & body的bufBadSchemaExceptionCopyright © 2019 Baidu, Inc.. All rights reserved.