升级代码组织
This commit is contained in:
@ -10,7 +10,7 @@ package mesh
|
||||
import (
|
||||
"context"
|
||||
"git.zhangdeman.cn/zhangdeman/consts"
|
||||
"git.zhangdeman.cn/zhangdeman/network/httpclient/cache"
|
||||
"git.zhangdeman.cn/zhangdeman/network/httpclient/abstract"
|
||||
"git.zhangdeman.cn/zhangdeman/network/httpclient/define"
|
||||
"sync"
|
||||
)
|
||||
@ -38,7 +38,7 @@ type RequestConfigGroupItem struct {
|
||||
RequestCfg *define.Request `json:"request_cfg"` // 请求配置
|
||||
FailBehavior *RequestConfigGroupItemFailBehavior `json:"fail_behavior"` // 失败的行为, 不配置, 默认失败break
|
||||
FinalFailureAllow bool `json:"final_failure_allow"` // 已经确定当前请求是最终失败了,当前请求是否允许执行
|
||||
CacheInstance cache.ICache `json:"-"` // 数据缓存实例
|
||||
CacheInstance abstract.ICache `json:"-"` // 数据缓存实例
|
||||
Condition any `json:"condition"` // TODO: 请求条件, 特定条件下不执行当前请求
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,9 @@ func (c *client) doRequest(apiList []*RequestConfigGroupItem) bool {
|
||||
apiCfg.RequestCfg.Header = param[strings.ToLower(consts.RequestDataLocationHeader.String())] // header
|
||||
apiCfg.RequestCfg.Cookie = param[strings.ToLower(consts.RequestDataLocationCookie.String())] // cookie
|
||||
apiCfg.RequestCfg.Query = param[strings.ToLower(consts.RequestDataLocationQuery.String())] // query
|
||||
if httpClient, err = httpclient.NewHttpClient(apiCfg.RequestCfg, apiCfg.CacheInstance); nil != err {
|
||||
if httpClient, err = httpclient.NewHttpClient(apiCfg.RequestCfg, &httpclient.RequestOption{
|
||||
CacheInstance: apiCfg.CacheInstance,
|
||||
}); nil != err {
|
||||
// 此处获取客户端实例即发生异常, 忽略一切配置, 直接作为全局失败, 后续也不请求了
|
||||
c.resp.ErrorCode = "-500"
|
||||
c.resp.ErrorMessage = err.Error()
|
||||
|
Reference in New Issue
Block a user