Documentation
¶
Index ¶
- Constants
- func EvalParams(req *bfe_basic.Request, params []*Param) []string
- func ValidateLegacyArgs(src string) error
- type BaseEnv
- func (e *BaseEnv) BackendAddr() string
- func (e *BaseEnv) BackendPort() int
- func (e *BaseEnv) Env(name string) string
- func (e *BaseEnv) LogInfo(msg string) bool
- func (e *BaseEnv) LogWarn(msg string) bool
- func (e *BaseEnv) ReqBody() string
- func (e *BaseEnv) ReqBodyJson(path string) string
- func (e *BaseEnv) ReqCip() string
- func (e *BaseEnv) ReqCookie(key string) string
- func (e *BaseEnv) ReqErr() string
- func (e *BaseEnv) ReqHeader(key string) string
- func (e *BaseEnv) ReqHost() string
- func (e *BaseEnv) ReqLogid() string
- func (e *BaseEnv) ReqMethod() string
- func (e *BaseEnv) ReqPath() string
- func (e *BaseEnv) ReqPort() string
- func (e *BaseEnv) ReqProto() string
- func (e *BaseEnv) ReqQuery(key string) string
- func (e *BaseEnv) ReqQueryAll(key string) []string
- func (e *BaseEnv) ReqQueryKeys() []string
- func (e *BaseEnv) ReqRetry() int
- func (e *BaseEnv) ReqSip() string
- func (e *BaseEnv) ReqTags(name string) []string
- func (e *BaseEnv) ReqUri() string
- func (e *BaseEnv) ReqVip() string
- func (e *BaseEnv) ReqVport() string
- func (e *BaseEnv) ResCode() int
- func (e *BaseEnv) ResHeader(key string) string
- func (e *BaseEnv) RouteCluster() string
- func (e *BaseEnv) RouteHostTag() string
- func (e *BaseEnv) RouteProduct() string
- func (e *BaseEnv) RouteSubCluster() string
- func (e *BaseEnv) SesSecure() bool
- func (e *BaseEnv) SesSni() string
- func (e *BaseEnv) SesTlsClientCa() string
- func (e *BaseEnv) SesTrusted() bool
- type Condition
- type ConfEnv
- type Env
- type GlbEnv
- func (e *GlbEnv) GlbVar(name string) string
- func (e *GlbEnv) GlbVarBool(name string) bool
- func (e *GlbEnv) GlbVarDecr(name string) int
- func (e *GlbEnv) GlbVarFloat(name string) float64
- func (e *GlbEnv) GlbVarIncr(name string) int
- func (e *GlbEnv) GlbVarIncrBy(name string, delta int) int
- func (e *GlbEnv) GlbVarInt(name string) int
- func (e *GlbEnv) GlbVarSetBool(name string, value bool) bool
- func (e *GlbEnv) GlbVarSetFloat(name string, value float64) float64
- func (e *GlbEnv) GlbVarSetInt(name string, value int) int
- func (e *GlbEnv) GlbVarSetStr(name, value string) string
- func (e *GlbEnv) GlbVarStr(name string) string
- type HashEnv
- type HttpClient
- func (c *HttpClient) Do(method, rawURL, contentType, body string, headerKv ...string) *HttpResp
- func (c *HttpClient) Get(rawURL string, headerKv ...string) *HttpResp
- func (c *HttpClient) Post(rawURL, contentType, body string, headerKv ...string) *HttpResp
- func (c *HttpClient) WithHeader(name, value string) *HttpClient
- type HttpEnv
- type HttpResp
- type InnerEnv
- func (e *InnerEnv) BfeBackendInfo() string
- func (e *InnerEnv) BfeBip() string
- func (e *InnerEnv) BfeCip() string
- func (e *InnerEnv) BfeClientIp() string
- func (e *InnerEnv) BfeClientIpLocation() string
- func (e *InnerEnv) BfeClientPort() string
- func (e *InnerEnv) BfeDomainAuto() string
- func (e *InnerEnv) BfeLogid() string
- func (e *InnerEnv) BfeProtocol() string
- func (e *InnerEnv) BfeRip() string
- func (e *InnerEnv) BfeRouteCluster() string
- func (e *InnerEnv) BfeServerName() string
- func (e *InnerEnv) BfeSslCipher() string
- func (e *InnerEnv) BfeSslInfo() string
- func (e *InnerEnv) BfeSslJa3Hash() string
- func (e *InnerEnv) BfeSslJa3Raw() string
- func (e *InnerEnv) BfeSslResume() string
- func (e *InnerEnv) BfeSslVersion() string
- func (e *InnerEnv) BfeVip() string
- func (e *InnerEnv) ClientCertAduCarRole() string
- func (e *InnerEnv) ClientCertAduReserve() string
- func (e *InnerEnv) ClientCertIssuerString() string
- func (e *InnerEnv) ClientCertPem() string
- func (e *InnerEnv) ClientCertPubKeyAlgo() string
- func (e *InnerEnv) ClientCertSerialNumber() string
- func (e *InnerEnv) ClientCertSigAlgo() string
- func (e *InnerEnv) ClientCertSubjectCommonName() string
- func (e *InnerEnv) ClientCertSubjectCountry() string
- func (e *InnerEnv) ClientCertSubjectLocality() string
- func (e *InnerEnv) ClientCertSubjectOrganization() string
- func (e *InnerEnv) ClientCertSubjectOrganizationUnit() string
- func (e *InnerEnv) ClientCertSubjectProvince() string
- func (e *InnerEnv) ClientCertSubjectString() string
- func (e *InnerEnv) ClientCertSubjectTitle() string
- func (e *InnerEnv) SessionId() string
- type LegacyEnv
- func (l *LegacyEnv) BfePeriodicTimeRange(start, end, period string) bool
- func (l *LegacyEnv) BfeTimeRange(start, end string) bool
- func (l *LegacyEnv) DefaultT() bool
- func (l *LegacyEnv) ReqBodyContain(patterns string, fold bool) bool
- func (l *LegacyEnv) ReqBodyJsonIn(path, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqCipHashIn(sections string) bool
- func (l *LegacyEnv) ReqCipRange(start, end string) bool
- func (l *LegacyEnv) ReqCipTrusted() bool
- func (l *LegacyEnv) ReqContextValueIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqCookieKeyIn(keys string) bool
- func (l *LegacyEnv) ReqCookieValueContain(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqCookieValueHashIn(key, sections string, insensitive bool) bool
- func (l *LegacyEnv) ReqCookieValueIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqCookieValuePrefixIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqCookieValueSuffixIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqHeaderKeyIn(keys string) bool
- func (l *LegacyEnv) ReqHeaderValueContain(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqHeaderValueHashIn(key, sections string, insensitive bool) bool
- func (l *LegacyEnv) ReqHeaderValueIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqHeaderValuePrefixIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqHeaderValueRegmatch(key, pattern string) bool
- func (l *LegacyEnv) ReqHeaderValueSuffixIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqHostIn(patterns string) bool
- func (l *LegacyEnv) ReqHostRegmatch(pattern string) bool
- func (l *LegacyEnv) ReqHostSuffixIn(patterns string) bool
- func (l *LegacyEnv) ReqHostTagIn(patterns string) bool
- func (l *LegacyEnv) ReqMethodIn(patterns string) bool
- func (l *LegacyEnv) ReqPathContain(patterns string, fold bool) bool
- func (l *LegacyEnv) ReqPathElementPrefixIn(patterns string, fold bool) bool
- func (l *LegacyEnv) ReqPathIn(patterns string, fold bool) bool
- func (l *LegacyEnv) ReqPathPrefixIn(patterns string, fold bool) bool
- func (l *LegacyEnv) ReqPathRegmatch(pattern string) bool
- func (l *LegacyEnv) ReqPathSuffixIn(patterns string, fold bool) bool
- func (l *LegacyEnv) ReqPortIn(patterns string) bool
- func (l *LegacyEnv) ReqProtoMatch(pattern string) bool
- func (l *LegacyEnv) ReqProtoSecure() bool
- func (l *LegacyEnv) ReqQueryExist() bool
- func (l *LegacyEnv) ReqQueryKeyIn(keys string) bool
- func (l *LegacyEnv) ReqQueryKeyPrefixIn(keys string) bool
- func (l *LegacyEnv) ReqQueryValueContain(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqQueryValueHashIn(key, sections string, insensitive bool) bool
- func (l *LegacyEnv) ReqQueryValueIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqQueryValuePrefixIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqQueryValueRegmatch(key, pattern string) bool
- func (l *LegacyEnv) ReqQueryValueSuffixIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) ReqTagMatch(key, value string) bool
- func (l *LegacyEnv) ReqUaRegmatch(pattern string) bool
- func (l *LegacyEnv) ReqUrlRegmatch(pattern string) bool
- func (l *LegacyEnv) ReqVipIn(patterns string) bool
- func (l *LegacyEnv) ReqVipRange(start, end string) bool
- func (l *LegacyEnv) ResCodeIn(patterns string) bool
- func (l *LegacyEnv) ResHeaderKeyIn(keys string) bool
- func (l *LegacyEnv) ResHeaderValueIn(key, patterns string, fold bool) bool
- func (l *LegacyEnv) SesSipRange(start, end string) bool
- func (l *LegacyEnv) SesTlsClientCaIn(patterns string) bool
- func (l *LegacyEnv) SesTlsSniIn(patterns string) bool
- func (l *LegacyEnv) SesVipRange(start, end string) bool
- type Param
- type RedisClient
- type RedisEnv
- type TimeEnv
- type VarEnv
- func (e *VarEnv) ReqContext(key interface{}) interface{}
- func (e *VarEnv) UsrVar(name string) string
- func (e *VarEnv) UsrVarBool(name string) bool
- func (e *VarEnv) UsrVarFloat(name string) float64
- func (e *VarEnv) UsrVarInt(name string) int
- func (e *VarEnv) UsrVarSet(name, value string) string
- func (e *VarEnv) UsrVarSetBool(name string, value bool) bool
- func (e *VarEnv) UsrVarSetFloat(name string, value float64) float64
- func (e *VarEnv) UsrVarSetInt(name string, value int) int
- func (e *VarEnv) UsrVarSetStr(name, value string) string
- func (e *VarEnv) UsrVarStr(name string) string
Constants ¶
const HashBucketSize = 10000
HashBucketSize 哈希桶空间,与旧条件原语 *_hash_in 保持一致
const HashMatcherBucketSize = 10000
HashMatcherBucketSize 旧哈希原语的桶空间
Variables ¶
This section is empty.
Functions ¶
func EvalParams ¶
EvalParams 运行期批量求值。单个参数求值失败 → 置空 + warn,继续执行; 数据缺失返回 ""(Env 约定,非错误)。
func ValidateLegacyArgs ¶
ValidateLegacyArgs 校验条件串中旧原语字面量参数(正则/哈希区间/时间格式), 使旧实现"加载期拒绝非法配置"的行为在新引擎下保持等价
Types ¶
type BaseEnv ¶
type BaseEnv struct {
// contains filtered or unexported fields
}
func (*BaseEnv) BackendAddr ¶
func (*BaseEnv) BackendPort ¶
func (*BaseEnv) ReqBodyJson ¶
ReqBodyJson 用 gjson 路径取请求体 JSON 字段,不存在返回 ""(结果按请求缓存)
func (*BaseEnv) ReqQueryAll ¶
ReqQueryAll 返回指定 query 参数的全部值
func (*BaseEnv) ReqQueryKeys ¶
ReqQueryKeys 返回全部 query key
func (*BaseEnv) RouteCluster ¶
func (*BaseEnv) RouteHostTag ¶
func (*BaseEnv) RouteProduct ¶
func (*BaseEnv) RouteSubCluster ¶
func (*BaseEnv) SesTlsClientCa ¶
SesTlsClientCa 返回签发客户端证书的 CA 名,无则 ""
func (*BaseEnv) SesTrusted ¶
SesTrusted 对端是否为可信来源(等价旧 req_cip_trusted)
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition 新风格条件表达式,实现 condition.Condition 接口(Match)
func CompileLegacy ¶
CompileLegacy 编译兼容旧原语的条件串: legacyPatcher 把旧原语名重写为 Env 方法后统一走新引擎,旧/新/混写均可。 先经 ValidateLegacyArgs 做旧原语字面量参数校验(对齐旧实现加载期拒绝非法配置的行为)。 编译失败时由调用方决定是否回退旧引擎。
func MustCompile ¶
MustCompile 同 Compile,编译失败时 panic(仅用于测试和确定的常量表达式)
type ConfEnv ¶
type ConfEnv struct{}
ConfEnv 提供配置表数据的表达式访问(本期 stub)
type Env ¶
type Env struct {
BaseEnv // ReqXxx / ResXxx / 路由集群 / SesXxx / Env / LogXxx
TimeEnv // Now / InTimeRange / InPeriodicRange
HashEnv // Hash / IpIn / IpRange / Rand / RandInt / Srand
VarEnv // ReqContext / UsrVarXxx / UsrVarSetXxx(请求级)
RedisEnv // GetRedisClient* / RedisClient.Get|GetInt|HGetAll,见 redis_env.go
HttpEnv // http 访问(本期 stub),见 http_env.go
GlbEnv // 进程级变量(本期 stub),见 glb_env.go
ConfEnv // 配置表访问(本期 stub),见 conf_env.go
InnerEnv // 旧 %var 内置变量函数(BfeClientIp 等),见 inner_env.go
LegacyEnv // 旧原语方法(ReqMethodIn 等),配合 legacyPatcher 兼容旧条件串
}
Env 是表达式求值上下文,按域拆分为多个子 env(匿名嵌入,方法提升)
type GlbEnv ¶
type GlbEnv struct{}
GlbEnv 进程级用户变量(本期 stub)
func (*GlbEnv) GlbVarBool ¶
GlbVarBool 读取 bool 型变量(本期 stub,返回 false)
func (*GlbEnv) GlbVarDecr ¶
GlbVarDecr 计数减一并返回新值(本期 stub,返回 0)
func (*GlbEnv) GlbVarFloat ¶
GlbVarFloat 读取 float64 型变量(本期 stub,返回 0)
func (*GlbEnv) GlbVarIncr ¶
GlbVarIncr 计数加一并返回新值(本期 stub,返回 0)
func (*GlbEnv) GlbVarIncrBy ¶
GlbVarIncrBy 计数加 delta 并返回新值(本期 stub,返回 0)
func (*GlbEnv) GlbVarSetBool ¶
GlbVarSetBool 写入 bool 型变量(本期 stub,返回写入值)
func (*GlbEnv) GlbVarSetFloat ¶
GlbVarSetFloat 写入 float64 型变量(本期 stub,返回写入值)
func (*GlbEnv) GlbVarSetInt ¶
GlbVarSetInt 写入 int 型变量(本期 stub,返回写入值)
func (*GlbEnv) GlbVarSetStr ¶
GlbVarSetStr 写入 string 型变量(本期 stub,返回写入值)
type HashEnv ¶
type HashEnv struct {
// contains filtered or unexported fields
}
func (*HashEnv) Hash ¶
Hash 返回 value 的哈希桶号 [0, HashBucketSize): murmur3(小写归一(value)) % HashBucketSize;value 为 "" 时返回本请求内稳定的随机桶。
func (*HashEnv) IpIn ¶
IpIn 判断 ip 是否命中 cidrs 列表,元素支持单 IP 和 CIDR(如 ["10.0.0.0/8"])。 ip 或列表元素解析失败按未命中处理。
type HttpClient ¶
type HttpClient struct{}
HttpClient http client 表达式句柄(本期 stub,所有方法返回零值)
func (*HttpClient) Do ¶
func (c *HttpClient) Do(method, rawURL, contentType, body string, headerKv ...string) *HttpResp
Do 发起请求(本期 stub)
func (*HttpClient) Get ¶
func (c *HttpClient) Get(rawURL string, headerKv ...string) *HttpResp
Get 发起 GET 请求(本期 stub)
func (*HttpClient) Post ¶
func (c *HttpClient) Post(rawURL, contentType, body string, headerKv ...string) *HttpResp
Post 发起 POST 请求(本期 stub)
func (*HttpClient) WithHeader ¶
func (c *HttpClient) WithHeader(name, value string) *HttpClient
WithHeader 返回带默认请求头的 client 副本(本期 stub)
type HttpEnv ¶
type HttpEnv struct{}
HttpEnv 提供表达式内的 http 访问函数(本期 stub)
func (*HttpEnv) GetHttpClient ¶
func (e *HttpEnv) GetHttpClient(timeoutMs int) *HttpClient
GetHttpClient 按超时返回 client(本期 stub)
func (*HttpEnv) HttpService ¶
func (e *HttpEnv) HttpService(name string) *HttpClient
HttpService 按名字获取 http 服务(本期 stub)
type HttpResp ¶
type HttpResp struct{}
HttpResp http 响应句柄(本期 stub,所有方法返回零值)
type InnerEnv ¶
type InnerEnv struct {
// contains filtered or unexported fields
}
InnerEnv 旧 %var 内置变量函数(委托 action.VariableHandlers,语义逐项等价)
func (*InnerEnv) BfeBackendInfo ¶
func (*InnerEnv) BfeClientIpLocation ¶
func (*InnerEnv) BfeClientPort ¶
func (*InnerEnv) BfeDomainAuto ¶
func (*InnerEnv) BfeProtocol ¶
func (*InnerEnv) BfeRouteCluster ¶
for backend BfeRouteCluster 对应旧变量 %bfe_cluster(路由目标集群 req.Route.ClusterName)。 注意与 BaseEnv.RouteCluster(后端集群 req.Backend.ClusterName)区分。
func (*InnerEnv) BfeSslCipher ¶
func (*InnerEnv) BfeSslJa3Hash ¶
func (*InnerEnv) BfeSslJa3Raw ¶
func (*InnerEnv) BfeSslResume ¶
func (*InnerEnv) BfeSslVersion ¶
func (*InnerEnv) ClientCertAduCarRole ¶
func (*InnerEnv) ClientCertAduReserve ¶
func (*InnerEnv) ClientCertIssuerString ¶
func (*InnerEnv) ClientCertPem ¶
func (*InnerEnv) ClientCertPubKeyAlgo ¶
func (*InnerEnv) ClientCertSerialNumber ¶
for client certificate
func (*InnerEnv) ClientCertSigAlgo ¶
func (*InnerEnv) ClientCertSubjectCommonName ¶
func (*InnerEnv) ClientCertSubjectCountry ¶
func (*InnerEnv) ClientCertSubjectLocality ¶
func (*InnerEnv) ClientCertSubjectOrganization ¶
func (*InnerEnv) ClientCertSubjectOrganizationUnit ¶
func (*InnerEnv) ClientCertSubjectProvince ¶
func (*InnerEnv) ClientCertSubjectString ¶
func (*InnerEnv) ClientCertSubjectTitle ¶
type LegacyEnv ¶
type LegacyEnv struct {
// contains filtered or unexported fields
}
LegacyEnv 旧原语方法集,方法内通过 env 调用新取数方法实现
func (*LegacyEnv) BfePeriodicTimeRange ¶
BfePeriodicTimeRange 旧 bfe_periodic_time_range:period 非空在旧实现为加载期报错,运行期按 false
func (*LegacyEnv) BfeTimeRange ¶
func (*LegacyEnv) ReqBodyContain ¶
ReqBodyContain 旧 req_body_contain(预留实现,legacyNameMap 暂不映射)
func (*LegacyEnv) ReqBodyJsonIn ¶
func (*LegacyEnv) ReqCipHashIn ¶
func (*LegacyEnv) ReqCipRange ¶
func (*LegacyEnv) ReqCipTrusted ¶
func (*LegacyEnv) ReqContextValueIn ¶
ReqContextValueIn 旧 req_context_value_in:Context 值须为 string,否则 false
func (*LegacyEnv) ReqCookieKeyIn ¶
func (*LegacyEnv) ReqCookieValueContain ¶
func (*LegacyEnv) ReqCookieValueHashIn ¶
func (*LegacyEnv) ReqCookieValueIn ¶
func (*LegacyEnv) ReqCookieValuePrefixIn ¶
func (*LegacyEnv) ReqCookieValueSuffixIn ¶
func (*LegacyEnv) ReqHeaderKeyIn ¶
func (*LegacyEnv) ReqHeaderValueContain ¶
func (*LegacyEnv) ReqHeaderValueHashIn ¶
func (*LegacyEnv) ReqHeaderValueIn ¶
func (*LegacyEnv) ReqHeaderValuePrefixIn ¶
func (*LegacyEnv) ReqHeaderValueRegmatch ¶
func (*LegacyEnv) ReqHeaderValueSuffixIn ¶
func (*LegacyEnv) ReqHostRegmatch ¶
func (*LegacyEnv) ReqHostSuffixIn ¶
func (*LegacyEnv) ReqHostTagIn ¶
func (*LegacyEnv) ReqMethodIn ¶
func (*LegacyEnv) ReqPathContain ¶
func (*LegacyEnv) ReqPathElementPrefixIn ¶
ReqPathElementPrefixIn 旧 req_path_element_prefix_in: 模式与路径都补尾 "/"(不重复补),fold 转大写后做前缀匹配
func (*LegacyEnv) ReqPathPrefixIn ¶
func (*LegacyEnv) ReqPathRegmatch ¶
func (*LegacyEnv) ReqPathSuffixIn ¶
func (*LegacyEnv) ReqProtoMatch ¶
func (*LegacyEnv) ReqProtoSecure ¶
func (*LegacyEnv) ReqQueryExist ¶
func (*LegacyEnv) ReqQueryKeyIn ¶
func (*LegacyEnv) ReqQueryKeyPrefixIn ¶
func (*LegacyEnv) ReqQueryValueContain ¶
func (*LegacyEnv) ReqQueryValueHashIn ¶
func (*LegacyEnv) ReqQueryValueIn ¶
func (*LegacyEnv) ReqQueryValuePrefixIn ¶
func (*LegacyEnv) ReqQueryValueRegmatch ¶
func (*LegacyEnv) ReqQueryValueSuffixIn ¶
func (*LegacyEnv) ReqTagMatch ¶
ReqTagMatch 旧 req_tag_match:tag 按 ":" 取首段比较
func (*LegacyEnv) ReqUaRegmatch ¶
func (*LegacyEnv) ReqUrlRegmatch ¶
func (*LegacyEnv) ReqVipRange ¶
func (*LegacyEnv) ResHeaderKeyIn ¶
func (*LegacyEnv) ResHeaderValueIn ¶
func (*LegacyEnv) SesSipRange ¶
func (*LegacyEnv) SesTlsClientCaIn ¶
SesTlsClientCaIn 旧 ses_tls_client_ca_in
func (*LegacyEnv) SesTlsSniIn ¶
func (*LegacyEnv) SesVipRange ¶
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
Param 代表一个动作参数:expr 表达式(加载期预编译)或字面量
func CompileParam ¶
CompileParam 加载期编译单个动作参数。 "=" 前缀按 expr 表达式编译(返回值必须 string);"==" 开头转义为字面量; 其余为普通字符串。编译失败返回错误(由调用方使配置加载失败,不回退)。
func CompileParams ¶
CompileParams 加载期批量编译(对应 []string params)
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
RedisClient redis client 表达式句柄(单例,进程级共享,勿按请求缓存)
func (*RedisClient) Get ¶
func (c *RedisClient) Get(key string) string
Get 读取 string 值;miss/错误/类型不符返回 ""
func (*RedisClient) GetInt ¶
func (c *RedisClient) GetInt(key string) int
GetInt 读取整数值(string 存储解析);miss/错误/解析失败返回 0
type RedisEnv ¶
type RedisEnv struct{}
RedisEnv 提供表达式内的 redis 访问函数
func (*RedisEnv) GetRedisClient ¶
func (e *RedisEnv) GetRedisClient(addr string) *RedisClient
GetRedisClient 按地址返回单例 redis client,使用默认超时/连接池参数。 addr 支持 bns 名或 ip:port(格式见 redis_client.Options.ServiceConf)。
func (*RedisEnv) GetRedisClientWithOpts ¶
func (e *RedisEnv) GetRedisClientWithOpts(addr, password string, connTimeoutMs, readTimeoutMs, writeTimeoutMs int) *RedisClient
GetRedisClientWithOpts 按地址与参数返回单例 redis client。 同一 地址+参数 组合只创建一次连接池,重复调用(含不同表达式/请求)返回同一实例; 相同 key 再次传入不同参数时,以首次创建的实例为准。
type TimeEnv ¶
type TimeEnv struct {
// contains filtered or unexported fields
}
func (*TimeEnv) InPeriodicRange ¶
InPeriodicRange 判断当前时刻是否落在每天周期时段内(闭区间)。 时间格式与旧 bfe_periodic_time_range 相同(hhmmssZ,Z 为时区)。
func (*TimeEnv) InTimeRange ¶
InTimeRange 判断 Now() 是否在 [start, end] 内(闭区间)。 时间格式与旧 bfe_time_range 相同(如 "2024-01-01 00:00:00 +0800");格式非法返回 false。
type VarEnv ¶
type VarEnv struct {
// contains filtered or unexported fields
}
func (*VarEnv) ReqContext ¶
func (e *VarEnv) ReqContext(key interface{}) interface{}
ReqContext 按 key 读取请求 Context 值,不存在返回 nil
func (*VarEnv) UsrVarBool ¶
UsrVarBool 读取 bool 型用户变量:原生 bool 直取;string 存储按 "true"/"false" 解析; 缺失/类型不符/解析失败返回 false
func (*VarEnv) UsrVarFloat ¶
UsrVarFloat 读取 float64 型用户变量:原生 float64 直取;string 存储则 ParseFloat 解析; 缺失/类型不符/解析失败返回 0
func (*VarEnv) UsrVarSetBool ¶
UsrVarSetBool 写入 bool 型用户变量,返回写入值
func (*VarEnv) UsrVarSetFloat ¶
UsrVarSetFloat 写入 float64 型用户变量,返回写入值
func (*VarEnv) UsrVarSetInt ¶
UsrVarSetInt 写入 int 型用户变量(原生类型入 Context),返回写入值
func (*VarEnv) UsrVarSetStr ¶
UsrVarSetStr 写入 string 型用户变量(与 legacy USR_VAR_SET 同一存储),返回写入值