struct.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package core
  2. import (
  3. "context"
  4. "errors"
  5. )
  6. type Stage uint8
  7. // These constants are meant to describe the stage in which the plugin is running.
  8. const (
  9. STAGE_START_RUN_END Stage = iota
  10. STAGE_START_RUN
  11. STAGE_START_END
  12. STAGE_RUN_END
  13. STAGE_START
  14. STAGE_END
  15. STAGE_RUN
  16. PROXY_CONNECTION_TYPE = "proxy_target_type"
  17. PROXY_CONNECTION_ADDR = "proxy_target_addr"
  18. PROXY_CONNECTION_PORT = "proxy_target_port"
  19. CLIENT_CONNECTION = "clientConn"
  20. BRIDGE = "bridge"
  21. CLIENT_ID = "client_id"
  22. )
  23. var (
  24. CLIENT_CONNECTION_NOT_EXIST = errors.New("the client connection is not exist")
  25. BRIDGE_NOT_EXIST = errors.New("the client connection is not exist")
  26. REQUEST_EOF = errors.New("the request has finished")
  27. CLIENT_ID_NOT_EXIST = errors.New("the request has finished")
  28. )
  29. // Plugin interface, all plugins must implement those functions.
  30. type Plugin interface {
  31. GetConfigName() *NpsConfigs
  32. GetBeforePlugin() Plugin
  33. GetStage() Stage
  34. Start(ctx context.Context, config map[string]string) error
  35. Run(ctx context.Context, config map[string]string) error
  36. End(ctx context.Context, config map[string]string) error
  37. }