Documentation
¶
Index ¶
- Constants
- type Api
- type Backend
- type Cache
- func (c *Cache) Api() *Api
- func (c *Cache) Data() *Data
- func (c *Cache) Eviction() *Eviction
- func (c *Cache) ForceGC() *ForceGC
- func (c *Cache) IsDebug() bool
- func (c *Cache) IsDev() bool
- func (c *Cache) IsEnabled() bool
- func (c *Cache) IsProd() bool
- func (c *Cache) IsTest() bool
- func (c *Cache) K8S() *K8S
- func (c *Cache) Refresh() *Refresh
- func (c *Cache) Rule(path string) (*Rule, bool)
- func (c *Cache) Runtime() *Runtime
- func (c *Cache) SetEnabled(v bool)
- func (c *Cache) Storage() *Storage
- func (c *Cache) Upstream() *Upstream
- type CacheBox
- type Cluster
- type Config
- type Data
- type Dump
- type Env
- type Eviction
- type ForceGC
- type K8S
- type Logs
- type Metrics
- type Mock
- type Probe
- type Refresh
- type Rule
- type RuleKey
- type RuleRefresh
- type RuleValue
- type Runtime
- type Storage
- type TraefikIntermediateConfig
- type Upstream
Constants ¶
View Source
const ( Prod = "prod" Dev = "dev" Debug = "debug" Test = "test" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶ added in v1.1.1
type Backend struct {
ID string `yaml:"id"`
Enabled bool `yaml:"enabled"`
Scheme string `yaml:"scheme"` // http or https
SchemeBytes []byte // virtual field, Scheme converted to []byte
Host string `yaml:"host"` // backend.example.com
HostBytes []byte // virtual field, Host converted to []byte
Rate int `yaml:"rate"` // Rate limiting reqs to backend per second.
Timeout time.Duration `yaml:"timeout"` // Timeout for requests to backend.
MaxTimeout time.Duration `yaml:"max_timeout"` // MaxTimeout for requests which are escape Timeout through UseMaxTimeoutHeaderBytes.
UseMaxTimeoutHeader string `yaml:"use_max_timeout_header"` // If the header exists the timeout above will be skipped.
UseMaxTimeoutHeaderBytes []byte // The same value but converted into slice bytes.
Healthcheck string `yaml:"healthcheck"` // Healthcheck or readiness probe path
HealthcheckBytes []byte // The same value but converted into slice bytes.
}
type Cache ¶
type Cache struct {
Cache *CacheBox `yaml:"cache"`
}
func LoadConfig ¶
func MustTestConfig ¶ added in v1.4.4
func MustTestConfig() *Cache
MustTestConfig panics on nil to simplify usage in tests.
func NewTestConfig ¶ added in v1.4.4
func NewTestConfig() *Cache
NewTestConfig returns a fully-populated *Cache mirroring the YAML you shared, including all computed "virtual" fields that LoadConfig sets (QueryBytes, HeadersMap, PathBytes, Backends' *Bytes fields, SoftMemoryLimit, and AtomicEnabled).
func (*Cache) SetEnabled ¶ added in v1.1.1
type CacheBox ¶
type CacheBox struct {
Env string `yaml:"env"`
Enabled bool `yaml:"enabled"`
AtomicEnabled atomic.Bool
CheckReloadInterval time.Duration `yaml:"cfg_reload_check_interval"`
Logs *Logs `yaml:"logs"`
Runtime *Runtime `yaml:"runtime"`
Api *Api `yaml:"api"`
Upstream *Upstream `yaml:"upstream"`
Data *Data `yaml:"data"`
Storage *Storage `yaml:"storage"`
Eviction *Eviction `yaml:"eviction"`
Refresh *Refresh `yaml:"refresh"`
ForceGC *ForceGC `yaml:"forceGC"`
Metrics *Metrics `yaml:"metrics"`
K8S *K8S `yaml:"k8s"`
Rules map[string]*Rule `yaml:"rules"`
}
type Refresh ¶
type Refresh struct {
Enabled bool `yaml:"enabled"`
// TTL - refresh TTL (max time life of response item in cache without refreshing).
TTL time.Duration `yaml:"ttl"` // e.g. "1d" (responses with 200 status code)
Rate int `yaml:"rate"` // Rate limiting to external backend.
ScanRate int64 `yaml:"scan_rate"` // Rate limiting of num scans items per second.
// beta определяет коэффициент, используемый для вычисления случайного момента обновления кэша.
// Чем выше beta, тем чаще кэш будет обновляться до истечения TTL.
// Формула взята из подхода "stochastic cache expiration" (см. Google Staleness paper):
// expireTime = ttl * (-beta * ln(random()))
// Подробнее: RFC 5861 и https://web.archive.org/web/20100829170210/http://labs.google.com/papers/staleness.pdf
// beta: "0.4"
Beta float64 `yaml:"beta"` // between 0 and 1
Coefficient float64 `yaml:"coefficient"` // Starts attempts to renew data after TTL*coefficient=50% (12h if whole TTL is 24h)
Replicas int32 `yaml:"replicas"`
}
type Rule ¶
type Rule struct {
CacheKey RuleKey `yaml:"cache_key"`
CacheValue RuleValue `yaml:"cache_value"`
Refresh *RuleRefresh `yaml:"refresh"`
PathBytes []byte // Virtual field
}
type RuleRefresh ¶ added in v1.0.1
type RuleRefresh struct {
Enabled bool `yaml:"enabled"`
// TTL - refresh TTL (max time life of response item in cache without refreshing).
TTL time.Duration `yaml:"ttl"` // e.g. "1d" (responses with 200 status code)
// beta определяет коэффициент, используемый для вычисления случайного момента обновления кэша.
// Чем выше beta, тем чаще кэш будет обновляться до истечения TTL.
// Формула взята из подхода "stochastic cache expiration" (см. Google Staleness paper):
// expireTime = ttl * (-beta * ln(random()))
// Подробнее: RFC 5861 и https://web.archive.org/web/20100829170210/http://labs.google.com/papers/staleness.pdf
// beta: "0.4"
Beta float64 `yaml:"beta"` // between 0 and 1
Coefficient float64 `yaml:"coefficient"` // Starts attempts to renew data after TTL*coefficient=50% (12h if whole TTL is 24h)
}
type TraefikIntermediateConfig ¶ added in v1.0.1
type TraefikIntermediateConfig struct {
ConfigPath string `yaml:"configPath" mapstructure:"configPath"`
}
Click to show internal directories.
Click to hide internal directories.