// Package define ... // // Description : define ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2025-03-28 14:12 package define import ( "git.zhangdeman.cn/zhangdeman/consts" "sync" ) // MeshRequestConfig 聚合请求 // // Author : go_developer@163.com<白茶清欢> // // Date : 14:14 2025/3/28 type MeshRequestConfig struct { CommonParam map[string]any `json:"common_param"` // 公共参数 Group [][]MeshRequestConfigGroupItem `json:"group"` // 请求分组 ResultRule []MeshRequestConfigResultRule `json:"result_rule"` // 结果提取规则, 多个接口的结果构造成一个返回结果 Receiver any `json:"-"` // 整体请求结果数据接收的指针 } // MeshRequestConfigGroupItem 分组请求每一项的结构 // // Author : go_developer@163.com<白茶清欢> // // Date : 14:16 2025/3/28 type MeshRequestConfigGroupItem struct { Alias string `json:"alias"` // 请求别名 ParamRuleList []MeshRequestConfigGroupItemParamRule `json:"param_rule_list"` // 参数规则列表 RequestCfg Request `json:"request_cfg"` // 请求配置 Condition any `json:"condition"` // TODO: 请求条件, 特定条件下不执行当前请求 } // MeshRequestConfigGroupItemParamRule 参数提取规则 // // Author : go_developer@163.com<白茶清欢> // // Date : 14:23 2025/3/28 type MeshRequestConfigGroupItemParamRule struct { Location consts.RequestDataLocation `json:"location"` // 参数位置 Path string `json:"path"` // 参数设置的路径 Type consts.DataType `json:"type"` // 参数类型 SourceAlias string `json:"source_alias"` // 数据源请求别名 __COMMON__ 代表从公共参数读取数据 SourceResultPath string `json:"source_result_path"` // 数据源数据, 从结果中获取的路径 } // MeshRequestConfigResultRule 返回值构建规则 // // Author : go_developer@163.com<白茶清欢> // // Date : 14:28 2025/3/28 type MeshRequestConfigResultRule struct { RequestAlias string `json:"request_alias"` // 请求别名 RequestResultLocation consts.ResponseDataLocation `json:"request_result_location"` // 请求结果位置 RequestResultPath string `json:"request_result_path"` // 请求结果路径 Location consts.ResponseDataLocation `json:"location"` // 返回值位置 DataPath string `json:"data_path"` // 返回值的路径 DataType consts.DataType `json:"data_type"` // 返回值类型 } // MeshResponse 聚合请求响应结果 // // Author : go_developer@163.com<白茶清欢> // // Date : 14:40 2025/3/28 type MeshResponse struct { Raw []byte `json:"raw"` // 返回结果的raw数据(按照result_rule格式化后的结果) DataMap map[string]any `json:"data_map"` // 返回结果的map格式(按照result_rule格式化后的结果) AliasResultTable map[string]Response `json:"alias_result_table"` // 每一个请求的返回结果 key: 请求别名 value: 请求返回数据 Lock *sync.RWMutex `json:"-"` // 数据锁, public, 外部拿到结果需要做一席并发读写操作, 可以直接服用这把所 }