public interface Protocol
| 限定符和类型 | 方法和说明 |
|---|---|
Object |
decode(DynamicCompositeByteBuf in)
客户端/服务端解析请求包成header+body buffer
|
void |
decodeHttpRequest(io.netty.handler.codec.http.FullHttpRequest httpRequest,
RpcRequest rpcRequest)
根据http request生成rpc request
|
RpcResponse |
decodeHttpResponse(io.netty.handler.codec.http.FullHttpResponse httpResponse,
io.netty.channel.ChannelHandlerContext ctx)
根据http response构建rpc response
|
void |
decodeRequest(Object packet,
RpcRequest rpcRequest)
服务端反序列化rpc请求
|
RpcResponse |
decodeResponse(Object packet,
io.netty.channel.ChannelHandlerContext ctx)
客户端反序列化rpc响应
|
io.netty.handler.codec.http.FullHttpRequest |
encodeHttpRequest(RpcRequest rpcRequest)
根据rpc request构建http request
|
io.netty.handler.codec.http.FullHttpResponse |
encodeHttpResponse(RpcRequest rpcRequest,
RpcResponse rpcResponse)
根据rpc response生成http response
|
io.netty.buffer.ByteBuf |
encodeRequest(RpcRequest rpcRequest)
客户端序列化请求对象
|
io.netty.buffer.ByteBuf |
encodeResponse(RpcResponse rpcResponse)
服务端序列化返回结果。
|
boolean |
returnChannelBeforeResponse()
连接被归还入池的时机
|
Object decode(DynamicCompositeByteBuf in) throws BadSchemaException, TooBigDataException, NotEnoughDataException
in - 输入byte bufBadSchemaException - header格式不对TooBigDataException - body太大NotEnoughDataException - 可读长度不够,由于粘包拆包问题。io.netty.buffer.ByteBuf encodeRequest(RpcRequest rpcRequest) throws Exception
rpcRequest - 待发送给服务端的对象Exception - 序列化异常RpcResponse decodeResponse(Object packet, io.netty.channel.ChannelHandlerContext ctx) throws Exception
packet - header & body的bufctx - netty channel contextException - 反序列化异常boolean returnChannelBeforeResponse()
void decodeRequest(Object packet, RpcRequest rpcRequest) throws Exception
packet - header & body的bufExceptionio.netty.buffer.ByteBuf encodeResponse(RpcResponse rpcResponse) throws Exception
rpcResponse - 服务端要返回给客户端的对象Exception - 序列化异常io.netty.handler.codec.http.FullHttpRequest encodeHttpRequest(RpcRequest rpcRequest) throws Exception
rpcRequest - ExceptionRpcResponse decodeHttpResponse(io.netty.handler.codec.http.FullHttpResponse httpResponse, io.netty.channel.ChannelHandlerContext ctx)
httpResponse - void decodeHttpRequest(io.netty.handler.codec.http.FullHttpRequest httpRequest,
RpcRequest rpcRequest)
httpRequest - io.netty.handler.codec.http.FullHttpResponse encodeHttpResponse(RpcRequest rpcRequest, RpcResponse rpcResponse)
rpcResponse - Copyright © 2018 Baidu, Inc.. All rights reserved.