From bbfc4d78bd3b74719e1e336ae4a781876b2b8381 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sun, 26 Sep 2021 15:02:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=9D=A1=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=9C=80=E5=B0=8F=E5=86=85=E5=AE=B9=E5=B0=BA=E5=AF=B8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/health_check_config.go | 4 ++-- pkg/serverconfigs/http_cache_ref.go | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/serverconfigs/health_check_config.go b/pkg/serverconfigs/health_check_config.go index dd4c579..07d1bec 100644 --- a/pkg/serverconfigs/health_check_config.go +++ b/pkg/serverconfigs/health_check_config.go @@ -5,7 +5,7 @@ import ( "github.com/iwind/TeaGo/maps" ) -// 健康检查设置 +// HealthCheckConfig 健康检查设置 type HealthCheckConfig struct { IsOn bool `yaml:"isOn" json:"isOn"` // 是否开启 URL string `yaml:"url" json:"url"` // 读取的URL @@ -21,7 +21,7 @@ type HealthCheckConfig struct { CountDown int `yaml:"countDown" json:"countDown"` // 连续离线认定次数 } -// 初始化 +// Init 初始化 func (this *HealthCheckConfig) Init() error { return nil } diff --git a/pkg/serverconfigs/http_cache_ref.go b/pkg/serverconfigs/http_cache_ref.go index aa8e94f..8d67ca8 100644 --- a/pkg/serverconfigs/http_cache_ref.go +++ b/pkg/serverconfigs/http_cache_ref.go @@ -15,7 +15,8 @@ type HTTPCacheRef struct { Key string `yaml:"key" json:"key"` // 每个缓存的Key规则,里面可以有变量 Life *shared.TimeDuration `yaml:"life" json:"life"` // 时间 Status []int `yaml:"status" json:"status"` // 缓存的状态码列表 - MaxSize *shared.SizeCapacity `yaml:"maxSize" json:"maxSize"` // 能够请求的最大尺寸 + MinSize *shared.SizeCapacity `yaml:"minSize" json:"minSize"` // 能够缓存的最小尺寸 + MaxSize *shared.SizeCapacity `yaml:"maxSize" json:"maxSize"` // 能够缓存的最大尺寸 SkipResponseCacheControlValues []string `yaml:"skipCacheControlValues" json:"skipCacheControlValues"` // 可以跳过的响应的Cache-Control值 SkipResponseSetCookie bool `yaml:"skipSetCookie" json:"skipSetCookie"` // 是否跳过响应的Set-Cookie Header @@ -29,11 +30,15 @@ type HTTPCacheRef struct { IsReverse bool `yaml:"isReverse" json:"isReverse"` // 是否为反向条件,反向条件的不缓存 lifeSeconds int64 + minSize int64 maxSize int64 uppercaseSkipCacheControlValues []string } func (this *HTTPCacheRef) Init() error { + if this.MinSize != nil { + this.minSize = this.MinSize.Bytes() + } if this.MaxSize != nil { this.maxSize = this.MaxSize.Bytes() } @@ -66,17 +71,22 @@ func (this *HTTPCacheRef) Init() error { return nil } -// 最大数据尺寸 +// MaxSizeBytes 最大数据尺寸 func (this *HTTPCacheRef) MaxSizeBytes() int64 { return this.maxSize } -// 生命周期 +// MinSizeBytes 最小数据尺寸 +func (this *HTTPCacheRef) MinSizeBytes() int64 { + return this.minSize +} + +// LifeSeconds 生命周期 func (this *HTTPCacheRef) LifeSeconds() int64 { return this.lifeSeconds } -// 是否包含某个Cache-Control值 +// ContainsCacheControl 是否包含某个Cache-Control值 func (this *HTTPCacheRef) ContainsCacheControl(value string) bool { return lists.ContainsString(this.uppercaseSkipCacheControlValues, strings.ToUpper(value)) }