Files
waf-platform/EdgeCommon/pkg/serverconfigs/access_log_write_targets.go
2026-02-10 23:43:05 +08:00

35 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright 2025. All rights reserved.
package serverconfigs
// AccessLogWriteTargets 访问日志写入目标(双写/单写文件、MySQL、ClickHouse
type AccessLogWriteTargets struct {
File bool `yaml:"file" json:"file"` // 写本地 JSON 文件(供 Fluent Bit → ClickHouse 或自用)
MySQL bool `yaml:"mysql" json:"mysql"` // 写 MySQL 默认库按日分表
ClickHouse bool `yaml:"clickhouse" json:"clickhouse"` // 标记需要 ClickHouse 查询链路(写入由文件+Fluent Bit 异步完成)
}
// NeedReportToAPI 是否需要上报到 API。
// 与 DNS 语义一致:仅 MySQL 打开时才上报 APIClickHouse-only 不上报。
func (t *AccessLogWriteTargets) NeedReportToAPI() bool {
if t == nil {
return true // 兼容:未配置时保持原行为,上报
}
return t.MySQL
}
// NeedWriteFile 节点是否需要写本地文件
func (t *AccessLogWriteTargets) NeedWriteFile() bool {
if t == nil {
return true // 兼容:未配置时保持原行为,写文件
}
return t.File
}
// ParseWriteTargetsFromPolicy 从策略字段解析写入目标。
// 当前以 type 为唯一真源writeTargetsJSON 参数仅保留函数签名兼容。
func ParseWriteTargetsFromPolicy(writeTargetsJSON []byte, policyType string, disableDefaultDB bool) *AccessLogWriteTargets {
_ = writeTargetsJSON
return BuildWriteTargetsByStorageType(policyType, disableDefaultDB)
}