plugins

package
v0.0.0-...-ae88a46 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

插件

plugins: # plugin list (sorted in alphabetical order)
  - api-breaker
  - authz-keycloak
  - basic-auth
  - batch-requests
  - consumer-restriction
  - cors
  # - dubbo-proxy
  - echo
  # - error-log-logger
  # - example-plugin
  - fault-injection
  - grpc-transcode
  - hmac-auth
  - http-logger
  - ip-restriction
  - jwt-auth
  - kafka-logger
  - key-auth
  - limit-conn
  - limit-count
  - limit-req
  # - log-rotate
  # - node-status
  - openid-connect
  - prometheus
  - proxy-cache
  - proxy-mirror
  - proxy-rewrite
  - redirect
  - referer-restriction
  - request-id
  - request-validation
  - response-rewrite
  - serverless-post-function
  - serverless-pre-function
  # - skywalking
  - sls-logger
  - syslog
  - tcp-logger
  - udp-logger
  - uri-blocker
  - wolf-rbac
  - zipkin
  - server-info
  - traffic-split
  - say

Documentation

Overview

Package plugins

@author: xwc1125

Package plugins

@author: xwc1125

Package plugins

@author: xwc1125

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingName                 = errors.New("missing name")
	ErrMissingParseConfMethod      = errors.New("missing ParseConf method")
	ErrMissingRequestFilterMethod  = errors.New("missing RequestFilter method")
	ErrMissingResponseFilterMethod = errors.New("missing ResponseFilter method")

	RequestPhase  = requestPhase{}  // 请求阶段
	ResponsePhase = responsePhase{} // 响应阶段
)

Functions

func ConfToProto

func ConfToProto(pluginName string, pluginConf string) []byte

ConfToProto plugin conf to proto bytes

func CreateRuleConf

func CreateRuleConf(uniqueKey string, entries []ConfInfo) []byte

func HTTPReqCall

func HTTPReqCall(key string, req *fasthttp.Request, resp *fasthttp.Response) error

HTTPReqCall http请求的调用

func HTTPRespCall

func HTTPRespCall(key string, resp *fasthttp.Response) error

HTTPRespCall http 响应的调用

func PrepareConf

func PrepareConf(key string, pluginsConf map[string]interface{}) (string, error)

PrepareConf 将请求的数据进行缓存

func RegisterPlugin

func RegisterPlugin(plugin Plugin) error

Types

type ConfCache

type ConfCache struct {
	// contains filtered or unexported fields
}

func InitConfCache

func InitConfCache(ttl time.Duration) *ConfCache

func (*ConfCache) Delete

func (cc *ConfCache) Delete(key string) error

func (*ConfCache) Get

func (cc *ConfCache) Get(key string) (RuleConf, error)

func (*ConfCache) Set

func (cc *ConfCache) Set(key string, pluginsConf map[string]interface{}) (string, error)

func (*ConfCache) SetIn

func (cc *ConfCache) SetIn(key string, entries RuleConf) error

type ConfEntry

type ConfEntry struct {
	Name  string      // 插件名
	Value interface{} // 插件配置信息对象
}

type ConfInfo

type ConfInfo struct {
	Name  string // 插件名
	Value string // 插件配置信息
}

type DefaultPlugin

type DefaultPlugin struct{}

DefaultPlugin 插件接口的无操作实现

func (*DefaultPlugin) RequestFilter

func (*DefaultPlugin) RequestFilter(conf interface{}, r *fasthttp.Request, w *fasthttp.Response) error

func (*DefaultPlugin) ResponseFilter

func (*DefaultPlugin) ResponseFilter(conf interface{}, w *fasthttp.Response) error

type ErrPluginRegistered

type ErrPluginRegistered struct {
	// contains filtered or unexported fields
}

func (ErrPluginRegistered) Error

func (err ErrPluginRegistered) Error() string

type Plugin

type Plugin interface {
	// Name 插件名称
	Name() string
	// Version 版本信息
	Version() string
	// Priority 优先级
	Priority() int64

	// ParseConf 解析插件配置
	// 如果无法解析,那么跳过改插件
	ParseConf(in []byte) (conf interface{}, err error)

	// RequestFilter 根据conf对象进行request的处理
	// 当err不为nil时,代表执行出错,那么将会直接返回错误。
	// 当w被改写时,即w.StatusCode!=fasthttp.StatusOK时,会跳出插件链的执行
	RequestFilter(conf interface{}, r *fasthttp.Request, w *fasthttp.Response) (err error)

	// ResponseFilter 对相应结果的处理
	ResponseFilter(conf interface{}, w *fasthttp.Response) (err error)
}

Plugin 插件接口

type Plugins

type Plugins []pluginRuntime

func (Plugins) Len

func (r Plugins) Len() int

func (Plugins) Less

func (r Plugins) Less(i, j int) bool

func (Plugins) Swap

func (r Plugins) Swap(i, j int)

type RuleConf

type RuleConf []ConfEntry

func GetRuleConf

func GetRuleConf(key string) (RuleConf, error)

GetRuleConf 从缓存中取数据

Directories

Path Synopsis
Package plugins
Package plugins
cgw
Package cgw
Package cgw
cgw/cgw_v2
Package cgw_v2
Package cgw_v2

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL