- 插件开发
- Server Plugin
- Client Plugin
插件开发
rpcx为服务器和客户端定义了几个插件接口,在一些处理点上可以调用插件。
Server Plugin
示例: trace
go doc
type PostConnAcceptPlugintype PostConnAcceptPlugin interface {HandleConnAccept(net.Conn) (net.Conn, bool)}type PostReadRequestPlugintype PostReadRequestPlugin interface {PostReadRequest(ctx context.Context, r *protocol.Message, e error) error}PostReadRequestPlugin represents .type PostWriteResponsePlugintype PostWriteResponsePlugin interface {PostWriteResponse(context.Context, *protocol.Message, *protocol.Message, error) error}PostWriteResponsePlugin represents .type PreReadRequestPlugintype PreReadRequestPlugin interface {PreReadRequest(ctx context.Context) error}PreReadRequestPlugin represents .type PreWriteResponsePlugintype PreWriteResponsePlugin interface {PreWriteResponse(context.Context, *protocol.Message) error}PreWriteResponsePlugin represents .
Client Plugin
go doc
type PluginContainertype PluginContainer interface {Add(plugin Plugin)Remove(plugin Plugin)All() []PluginDoPreCall(ctx context.Context, servicePath, serviceMethod string, args interface{}) errorDoPostCall(ctx context.Context, servicePath, serviceMethod string, args interface{}, reply interface{}, err error) error}type PostCallPlugintype PostCallPlugin interface {DoPostCall(ctx context.Context, servicePath, serviceMethod string, args interface{}, reply interface{}, err error) error}PostCallPlugin is invoked after the client calls a server.type PreCallPlugintype PreCallPlugin interface {DoPreCall(ctx context.Context, servicePath, serviceMethod string, args interface{}) error}PreCallPlugin is invoked before the client calls a server.
