Plugin developement

Server Plugin

Example:trace

go doc

  1. type PostConnAcceptPlugin
  2. type PostConnAcceptPlugin interface {
  3. HandleConnAccept(net.Conn) (net.Conn, bool)
  4. }
  5. PostConnAcceptPlugin represents connection accept plugin. if returns false, it means subsequent IPostConnAcceptPlugins should not contiune to handle this conn and this conn has been closed.
  6. type PostReadRequestPlugin
  7. type PostReadRequestPlugin interface {
  8. PostReadRequest(ctx context.Context, r *protocol.Message, e error) error
  9. }
  10. PostReadRequestPlugin represents .
  11. type PostWriteResponsePlugin
  12. type PostWriteResponsePlugin interface {
  13. PostWriteResponse(context.Context, *protocol.Message, *protocol.Message, error) error
  14. }
  15. PostWriteResponsePlugin represents .
  16. type PreReadRequestPlugin
  17. type PreReadRequestPlugin interface {
  18. PreReadRequest(ctx context.Context) error
  19. }
  20. PreReadRequestPlugin represents .
  21. type PreWriteResponsePlugin
  22. type PreWriteResponsePlugin interface {
  23. PreWriteResponse(context.Context, *protocol.Message) error
  24. }
  25. PreWriteResponsePlugin represents .

Client Plugin

go doc

  1. type PluginContainer
  2. type PluginContainer interface {
  3. Add(plugin Plugin)
  4. Remove(plugin Plugin)
  5. All() []Plugin
  6. DoPreCall(ctx context.Context, servicePath, serviceMethod string, args interface{}) error
  7. DoPostCall(ctx context.Context, servicePath, serviceMethod string, args interface{}, reply interface{}, err error) error
  8. }
  9. PluginContainer represents a plugin container that defines all methods to manage plugins. And it also defines all extension points.
  10. type PostCallPlugin
  11. type PostCallPlugin interface {
  12. DoPostCall(ctx context.Context, servicePath, serviceMethod string, args interface{}, reply interface{}, err error) error
  13. }
  14. PostCallPlugin is invoked after the client calls a server.
  15. type PreCallPlugin
  16. type PreCallPlugin interface {
  17. DoPreCall(ctx context.Context, servicePath, serviceMethod string, args interface{}) error
  18. }
  19. PreCallPlugin is invoked before the client calls a server.

By smallnest updated 2018-03-27 11:12:10

原文:

http://doc.rpcx.site/part4/plugin-dev.html