增加插件接口及插件结果定义
This commit is contained in:
@ -21,13 +21,30 @@ import (
|
||||
//
|
||||
// Date : 17:19 2024/11/11
|
||||
type RequestContext struct {
|
||||
ctx context.Context `json:"-"` // gin 上下文
|
||||
runtimeInstance *trace.Runtime `json:"-"` // 链路统一追踪实例
|
||||
lock *sync.RWMutex `json:"-"` // 数据锁
|
||||
TraceID string `json:"trace_id"` // 全链路追踪的trace_id
|
||||
GatewayUrlConfig *ApiConfig `json:"gateway_url_config"` // 网关接口的配置
|
||||
RequestInfo *RequestInfo `json:"request_info"` // 网关请求信息
|
||||
BackendApiResultTable map[string]*httpclientDefine.Response `json:"backend_api_result_table"` // 后端接口返回数据详细信息: 接口别名 => 请求结果
|
||||
ctx context.Context // ctx 上下文
|
||||
runtimeInstance *trace.Runtime // 链路统一追踪实例
|
||||
lock *sync.RWMutex // 数据锁
|
||||
traceID string // 全链路追踪的trace_id
|
||||
gatewayUrlConfig *ApiConfig // 网关接口的配置
|
||||
requestInfo *RequestInfo // 网关请求信息
|
||||
backendApiResultTable map[string]*httpclientDefine.Response // 后端接口返回数据详细信息: 接口别名 => 请求结果
|
||||
pluginResultTable map[string][]*PluginResult // 插件执行结果记录
|
||||
}
|
||||
|
||||
// SetPluginResult 设置插件执行结果
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:53 2024/11/13
|
||||
func (rc *RequestContext) SetPluginResult(r *PluginResult) {
|
||||
rc.Lock()
|
||||
defer rc.Unlock()
|
||||
|
||||
// 一次请求中, 同一个插件可能多次执行
|
||||
if v, exist := rc.pluginResultTable[r.ID]; !exist || nil == v {
|
||||
rc.pluginResultTable[r.ID] = make([]*PluginResult, 0)
|
||||
}
|
||||
rc.pluginResultTable[r.ID] = append(rc.pluginResultTable[r.ID], r)
|
||||
}
|
||||
|
||||
func (rc *RequestContext) Lock() {
|
||||
|
Reference in New Issue
Block a user