add traffic reset for stats

This commit is contained in:
ginuerzh
2024-12-24 20:11:22 +08:00
parent 914a4622fd
commit 06d993023f
41 changed files with 407 additions and 143 deletions
+8 -6
View File
@@ -18,7 +18,8 @@ type metadata struct {
header http.Header
hash string
authBasicRealm string
observePeriod time.Duration
observerPeriod time.Duration
observerResetTraffic bool
limiterRefreshInterval time.Duration
}
@@ -43,13 +44,14 @@ func (h *http2Handler) parseMetadata(md mdata.Metadata) error {
h.md.hash = mdutil.GetString(md, "hash")
h.md.authBasicRealm = mdutil.GetString(md, "authBasicRealm")
h.md.observePeriod = mdutil.GetDuration(md, "observePeriod", "observer.observePeriod")
if h.md.observePeriod == 0 {
h.md.observePeriod = 5 * time.Second
h.md.observerPeriod = mdutil.GetDuration(md, "observePeriod", "observer.period", "observer.observePeriod")
if h.md.observerPeriod == 0 {
h.md.observerPeriod = 5 * time.Second
}
if h.md.observePeriod < time.Second {
h.md.observePeriod = time.Second
if h.md.observerPeriod < time.Second {
h.md.observerPeriod = time.Second
}
h.md.observerResetTraffic = mdutil.GetBool(md, "observer.resetTraffic")
h.md.limiterRefreshInterval = mdutil.GetDuration(md, "limiter.refreshInterval")
if h.md.limiterRefreshInterval == 0 {