Documentation
¶
Index ¶
- Constants
- Variables
- func ConfModAccessPbCheck(cfg *ConfModAccessPb2, confRoot string) error
- func ConnAddrInfoGen(session *bfe_basic.Session) *bfe_access_pb3.ConnAddrInfo
- type AccessHeaderConf
- type ConfModAccessPb2
- type ModAccessPbConf
- type ModAccessPbConfHolder
- type ModuleAccessLogState
- type ModuleAccessPb3
Constants ¶
const ( DEF_REQ_BODY_LOGRATE = 1000 MAX_REQ_BODY_LOGRATE = 2000 )
const (
BFE_MOD_ACCESS_PB3 = "mod_access_pb3"
)
Variables ¶
var ( BFE_PRODUCT_ID = (*bfe_access_pb3.ProductID)( proto.Int32(int32(bfe_access_pb3.ProductID_BFE))) LOG_TYPE_REQ = (*bfe_access_pb3.BfeLogType)( proto.Int32(int32(bfe_access_pb3.BfeLogType_Request))) LOG_TYPE_SESSION = (*bfe_access_pb3.BfeLogType)( proto.Int32(int32(bfe_access_pb3.BfeLogType_Session))) )
Functions ¶
func ConfModAccessPbCheck ¶
func ConfModAccessPbCheck(cfg *ConfModAccessPb2, confRoot string) error
func ConnAddrInfoGen ¶
func ConnAddrInfoGen(session *bfe_basic.Session) *bfe_access_pb3.ConnAddrInfo
Types ¶
type AccessHeaderConf ¶ added in v1.10.0
AccessHeaderConf is the in-memory form of the "access_header" section: whitelists of request/response headers collected into the proto fields req_headers (55) / res_headers (158). Names are stored in HTTP canonical form (see normalizeHeaderNames).
type ConfModAccessPb2 ¶
type ConfModAccessPb2 struct {
Log struct {
LogPrefix string // log file prefix
LogDir string // log file dir
RotateWhen string // rotate time
BackupCount int // log file backup number
}
BasicConf struct {
OpenDebug bool // whether open debug
// DataConfPath is the path of mod_access_pb.data, the dynamic
// (hot-reloadable) configuration file of this module. Relative
// paths are resolved against the conf root (same rule as
// mod_ai_route.RouteRulePath). Optional: when empty, the module
// runs without dynamic config (default behavior, no whitelisted
// headers). A configured-but-missing data file is tolerated at
// startup with a warning, keeping upgrades behavior-compatible
// for deployments that do not create the file yet.
DataConfPath string
}
}
func ConfLoad ¶
func ConfLoad(filePath string, confRoot string) (*ConfModAccessPb2, error)
load config from config file
func (*ConfModAccessPb2) Check ¶
func (cfg *ConfModAccessPb2) Check(confRoot string) error
type ModAccessPbConf ¶ added in v1.10.0
type ModAccessPbConf struct {
Version string
AccessHeader AccessHeaderConf
}
ModAccessPbConf is the in-memory form of mod_access_pb.data. New dynamic configuration sections are added here as new fields.
func ModAccessPbDataLoad ¶ added in v1.10.0
func ModAccessPbDataLoad(path string) (*ModAccessPbConf, error)
ModAccessPbDataLoad loads and validates mod_access_pb.data. It returns an error for any malformed content; the caller decides whether a missing file is tolerable (it is at module Init).
type ModAccessPbConfHolder ¶ added in v1.10.0
type ModAccessPbConfHolder struct {
// contains filtered or unexported fields
}
ModAccessPbConfHolder guards the runtime config with an RWMutex: validation happens outside the lock (in ModAccessPbDataLoad), Update only swaps the reference under the write lock, and readers take the snapshot under the read lock. A reload therefore never exposes a half-new/half-old config, and a failed reload keeps the old one.
func NewModAccessPbConfHolder ¶ added in v1.10.0
func NewModAccessPbConfHolder() *ModAccessPbConfHolder
func (*ModAccessPbConfHolder) Snapshot ¶ added in v1.10.0
func (h *ModAccessPbConfHolder) Snapshot() *ModAccessPbConf
func (*ModAccessPbConfHolder) Update ¶ added in v1.10.0
func (h *ModAccessPbConfHolder) Update(c *ModAccessPbConf)
type ModuleAccessLogState ¶
type ModuleAccessLogState struct {
AllReqLogCount *metrics.Counter
AllSesLogCount *metrics.Counter
// AiUsageSuppressed counts ACCESS-LOG rows whose AI token fields were
// withheld because the request has no reportable usage (issue #1409):
// either nothing reached model auth and nothing was accumulated, or a
// non-2xx response's EstimateToken residue was dropped and the row
// suppressed (issue #1493 restores this coverage after #1480 had moved
// such rows to Non2xxUsageReported, now Non2xxEstimateDropped again).
AiUsageSuppressed *metrics.Counter
// AiUsageInconsistent counts rows whose token triple breaks the billing
// yardstick invariant ai_total_tokens == ai_input_tokens +
// ai_output_tokens (image/video count rows excepted). It must stay 0;
// a non-zero value means a new code path writes partial usage.
AiUsageInconsistent *metrics.Counter
// LogidRegenerated counts request logs whose logid could not be converted
// from req.LogId (empty when mod_logid is not loaded, malformed value, or a
// legacy 32-char hex logid seen while an uplevel BFE is still on the old
// version) and was therefore regenerated locally. The row still carries a
// unique non-zero logid, so it is safe to dedup; only the correlation with
// the string logid is lost. It must stay 0 in steady state
// (bfenetworks/bfe#1417).
LogidRegenerated *metrics.Counter
// SessionIdRegenerated counts the same fallback for the session id column
// (shared by RequestLog.session_id and the session log's logid)
// (bfenetworks/bfe#1417).
SessionIdRegenerated *metrics.Counter
}
type ModuleAccessPb3 ¶
type ModuleAccessPb3 struct {
// contains filtered or unexported fields
}
func NewModuleAccessPb3 ¶
func NewModuleAccessPb3() *ModuleAccessPb3
func (*ModuleAccessPb3) Close ¶
func (m *ModuleAccessPb3) Close() error
func (*ModuleAccessPb3) Init ¶
func (m *ModuleAccessPb3) Init(cbs *bfe_module.BfeCallbacks, whs *web_monitor.WebHandlers, cr string) error
func (*ModuleAccessPb3) Name ¶
func (m *ModuleAccessPb3) Name() string