增加requestcontext实例化
This commit is contained in:
parent
7e30b1f8b9
commit
ad874d13f6
@ -9,12 +9,30 @@ package define
|
||||
|
||||
import (
|
||||
"context"
|
||||
httpclientDefine "git.zhangdeman.cn/gateway/httpclient/define"
|
||||
validatorDefine "git.zhangdeman.cn/gateway/validator/define"
|
||||
"git.zhangdeman.cn/zhangdeman/trace"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// NewRequestContext 获取context实例
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:44 2024/11/20
|
||||
func NewRequestContext(ctx context.Context, traceID string) *RequestContext {
|
||||
if nil == ctx {
|
||||
ctx = context.Background()
|
||||
}
|
||||
return &RequestContext{
|
||||
ctx: ctx,
|
||||
runtimeInstance: trace.NewRuntime(traceID, 1),
|
||||
lock: &sync.RWMutex{},
|
||||
traceID: traceID,
|
||||
pluginResultTable: make(map[string][]*PluginResult),
|
||||
data: make(map[string]any),
|
||||
}
|
||||
}
|
||||
|
||||
// RequestContext 请求配置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
@ -25,10 +43,8 @@ type RequestContext struct {
|
||||
runtimeInstance *trace.Runtime // 链路统一追踪实例
|
||||
lock *sync.RWMutex // 数据锁
|
||||
traceID string // 全链路追踪的trace_id
|
||||
gatewayUrlConfig *ApiConfig // 网关接口的配置
|
||||
requestInfo *RequestInfo // 网关请求信息
|
||||
backendApiResultTable map[string]*httpclientDefine.Response // 后端接口返回数据详细信息: 接口别名 => 请求结果
|
||||
pluginResultTable map[string][]*PluginResult // 插件执行结果记录
|
||||
data map[string]any // 自定义设置的数据
|
||||
}
|
||||
|
||||
// SetPluginResult 设置插件执行结果
|
||||
|
Loading…
Reference in New Issue
Block a user