Documentation
¶
Index ¶
- Constants
- type Admission
- type Api
- type Backend
- type Cache
- func (c *Cache) Admission() *Admission
- func (c *Cache) Api() *Api
- func (c *Cache) Compression() *Compression
- 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) Lifetime() *Lifetime
- func (c *Cache) Logs() *Logs
- func (c *Cache) Observability() *Observability
- 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 Compression
- type Config
- type Data
- type Dump
- type Env
- type Eviction
- type ForceGC
- type K8S
- type Lifetime
- type LifetimeRule
- type Logs
- type Metrics
- type Mock
- type Observability
- type Probe
- type Rule
- type RuleKey
- type RuleValue
- type Runtime
- type SamplingMode
- type Storage
- type TTLMode
- 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 Admission ¶ added in v1.6.0
type Admission struct {
Enabled bool `yaml:"enabled"`
IsEnabled atomic.Bool // virtual field; sets while init.
Capacity int `yaml:"capacity"`
Shards int `yaml:"shards"`
MinTableLenPerShard int `yaml:"min_table_len_per_shard"`
SampleMultiplier int `yaml:"sample_multiplier"`
DoorBitsPerCounter int `yaml:"door_bits_per_counter"`
}
type Backend ¶ added in v1.1.1
type Backend struct {
ID string `yaml:"id"`
IDBytes []byte
Enabled bool `yaml:"enabled"`
Policy string `yaml:"policy"`
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.
Concurrency int `yaml:"concurrency"` // Mux concurrency (in-flight reqs).
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 NewTestConfig ¶ added in v1.4.4
func NewTestConfig() *Cache
func (*Cache) Compression ¶ added in v1.7.1
func (c *Cache) Compression() *Compression
func (*Cache) Observability ¶ added in v1.8.0
func (c *Cache) Observability() *Observability
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"`
Compression *Compression `yaml:"compression"`
Eviction *Eviction `yaml:"eviction"`
Admission *Admission `yaml:"admission"`
Observability *Observability `yaml:"observability"`
Lifetime *Lifetime `yaml:"lifetime"`
ForceGC *ForceGC `yaml:"forceGC"`
Metrics *Metrics `yaml:"metrics"`
K8S *K8S `yaml:"k8s"`
Rules map[string]*Rule `yaml:"rules"`
}
type Compression ¶ added in v1.7.1
*
- Compression
- - Supported levels:
- CompressNoCompression = 0
- CompressBestSpeed = 1
- CompressBestCompression = 9
- CompressDefaultCompression = 6 // flate.DefaultCompression
- CompressHuffmanOnly = -2 // flate.HuffmanOnly
type Config ¶ added in v1.1.1
type Config interface {
Logs() *Logs
IsProd() bool
IsDebug() bool
IsEnabled() bool
SetEnabled(v bool)
Runtime() *Runtime
Api() *Api
Upstream() *Upstream
Data() *Data
Lifetime() *Lifetime
Eviction() *Eviction
Admission() *Admission
Observability() *Observability
Storage() *Storage
Compression() *Compression
K8S() *K8S
ForceGC() *ForceGC
Rule(path string) (*Rule, bool)
}
type Eviction ¶
type Eviction struct {
Enabled bool `yaml:"enabled"`
SoftLimit float64 `yaml:"soft_limit"` // 0.80 means 80%
HardLimit float64 `yaml:"hard_limit"` // 0.85 means 85%
Replicas int `yaml:"replicas"`
Interval time.Duration `yaml:"check_interval"` // Defines how often the main evictor loop will check the memory limit.
}
type Lifetime ¶ added in v0.9.0
type Lifetime struct {
Enabled bool `yaml:"enabled"`
OnTTL TTLMode `yaml:"on_ttl"`
// 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)
Replicas int `yaml:"replicas"`
Rate int `yaml:"rate"` // Rate limiting to external backend.
// 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)
IsRemoveOnTTL atomic.Bool // virtual, computes while init.
}
type LifetimeRule ¶ added in v1.7.0
type LifetimeRule 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 Observability ¶ added in v1.8.0
type Observability struct {
Enabled bool `yaml:"enabled"` // hard toggle
ServiceName string `yaml:"service_name"` // "adv-cache"
ServiceVersion string `yaml:"service_version"` // "dev|prod|test"
ServiceTenant string `yaml:"service_tenant"` // X_Scope_OTEL_Tenant attribute value
Exporter string `yaml:"exporter"` // "grpc"|"http"|"stdout"
Endpoint string `yaml:"endpoint"` // "127.0.0.1:4317" or "127.0.0.1:4318"
Insecure bool `yaml:"insecure"` // allow insecure local dev
SamplingMode SamplingMode `yaml:"sampling_mode"` // off|always|ratio
SamplingRate float64 `yaml:"sampling_rate"` // 0..1, used when mode=ratio
ExportBatchSize int `yaml:"export_batch_size"` // default: 512
ExportBatchTimeout time.Duration `yaml:"export_batch_timeout"` // default: 2s
ExportMaxQueue int `yaml:"export_max_queue"` // max queue for export
}
type Rule ¶
type Rule struct {
Path string // Virtual field
PathBytes []byte // Virtual field
CacheKey RuleKey `yaml:"cache_key"`
CacheValue RuleValue `yaml:"cache_value"`
Lifetime *LifetimeRule `yaml:"refresh"`
}
type SamplingMode ¶ added in v1.8.0
type SamplingMode string
const ( SamplingOff SamplingMode = "off" // never record SamplingAlways SamplingMode = "always" // record all SamplingRatio SamplingMode = "ratio" // ParentBased(TraceIDRatioBased) )
type Storage ¶
type Storage struct {
Mode string `yaml:"mode"` // sampling or listing
IsListing bool // virtual, fills while init.
Size int64 `yaml:"size"` // soft and hard evictions based on this
SoftMemoryLimit int64 // virtual, fills while init.
HardMemoryLimit int64 // virtual, fills while init.
AdmissionMemoryLimit int64 // virtual, fills while init.
}
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.