Versions in this module Expand all Collapse all v1 v1.1.0 Oct 13, 2026 Changes in this version + var ErrRequestBody = errors.New("weir: request body read failed") + var ErrRequestBodyTimeout = errors.New("weir: request body timed out") type BreakerConfig + MinPartitions int type Config + func (c Config) KeyGeneration() string type LimiterConfig + MaxPerClient int + PartitionHeadroom int type Request + Client string + PassThrough bool v1.1.0-rc.1 Oct 13, 2026 v1.0.1 Oct 12, 2026 v1.0.0 Oct 12, 2026 Changes in this version type Config + Experiments ExperimentsConfig type Engine + func (e *Engine) Purge(ctx context.Context, p Purge) error + func (e *Engine) Stats() EngineStats type Event + Experiment string + Variant string + Visitor string type EventKind + const EvExposure + type ExperimentConfig struct + Host string + Name string + Path string + Salt string + Variants []VariantConfig + Winner string + type ExperimentConsent struct + Cookie string + Value string + type ExperimentsConfig struct + Consent ExperimentConsent + Cookie string + DownstreamKeysOnVariant bool + Experiments []ExperimentConfig + Header string + MaxActive int + SigningKeys [][]byte + type VariantConfig struct + Name string + Weight int v1.0.0-rc.3 Oct 12, 2026 v1.0.0-rc.1 Oct 12, 2026 v0 v0.1.0 Oct 5, 2026 Changes in this version + var ErrCircuitOpen = errors.New("weir: origin circuit open") + var ErrClosed = errors.New("weir: engine closed") + var ErrEagerUnsupported = errors.New("weir: store cannot scrub; epoch written, delete skipped") + var ErrInvalidConfig = errors.New("weir: invalid config") + var ErrInvalidRequest = errors.New("weir: invalid request") + var ErrMustRevalidate = errors.New("weir: must-revalidate response could not be validated") + var ErrOnlyIfCached = errors.New("weir: only-if-cached and no stored response") + var ErrOrigin = errors.New("weir: origin error") + var ErrOriginTimeout = errors.New("weir: origin timeout") + var ErrShed = errors.New("weir: origin capacity exhausted") + var ErrUpgradeNotSupported = errors.New("weir: connect and protocol upgrades not supported") + func RetryAfter(err error) (time.Duration, bool) + func StatusCode(err error) int + func TrackingParams() []string + type BreakerConfig struct + CountStatus500 bool + Disable bool + FailureRatio float64 + HalfOpenProbes int + MaxOpenFor time.Duration + MinRequests int + OpenFor time.Duration + Window time.Duration + type BreakerState uint8 + const BreakerClosed + const BreakerHalfOpen + const BreakerOpen + type BypassConfig struct + Cookies []string + Headers []string + ReportStrippedCookies time.Duration + type CacheGroupsConfig struct + Ignore bool + type CacheInfo struct + Collapsed bool + Detail string + Fwd FwdReason + FwdStatus int + Hit bool + Stale StaleReason + Stored bool + TTL time.Duration + type ClientConfig struct + HonorRevalidation bool + type CoalesceConfig struct + FollowerMaxWait time.Duration + HitForMissTTL time.Duration + LeaderMaxAge time.Duration + type Config struct + Breaker BreakerConfig + Bypass BypassConfig + CacheGroups CacheGroupsConfig + CacheStatus string + Client ClientConfig + Coalesce CoalesceConfig + Forward ForwardConfig + Freshness FreshnessConfig + Key KeyConfig + Limiter LimiterConfig + Limits LimitsConfig + Logger *slog.Logger + MissRate MissRateConfig + Negative NegativeConfig + NoCacheStatus bool + Observer Observer + Rand func() float64 + Storable StorableConfig + Store store.Store + Timeouts TimeoutsConfig + Warm WarmConfig + type Engine struct + func New(cfg Config) (*Engine, error) + func (e *Engine) Close(ctx context.Context) error + func (e *Engine) Serve(ctx context.Context, req *Request, origin Origin) (*Response, error) + func (e *Engine) SetMode(m Mode, ttl time.Duration) error + func (e *Engine) Warm(ctx context.Context, reqs iter.Seq[*Request], origin Origin) (WarmStats, error) + type EngineStats struct + BreakerState BreakerState + Inflight int + Queued int + StoreBytes int64 + type Event struct + Duration time.Duration + Info CacheInfo + Kind EventKind + Partition string + Reason string + Status int + Time time.Time + type EventKind uint8 + const EvBreakerState + const EvCoalesceJoin + const EvCoalesceTimeout + const EvEvict + const EvFetchEnd + const EvFetchStart + const EvKeyRejected + const EvMissRateAnomaly + const EvMode + const EvNegativeServed + const EvNotStored + const EvPurge + const EvRefreshDropped + const EvRequest + const EvShed + const EvStaleServed + const EvStoreBreaker + const EvStoreError + const EvVaryOverflow + func (k EventKind) String() string + type ForwardConfig struct + Allow []string + Mode ForwardMode + NoTraceHeaders bool + type ForwardMode uint8 + const ForwardAll + const ForwardStrict + type FreshnessConfig struct + DefaultStaleIfError time.Duration + DefaultStaleWhileRevalidate time.Duration + DefaultTTL time.Duration + EarlyRefreshBeta float64 + HeuristicFraction float64 + HeuristicMax time.Duration + Jitter float64 + JitterMinLifetime time.Duration + Keep time.Duration + NoEarlyRefresh bool + NoJitter bool + type FwdReason uint8 + const FwdBypass + const FwdMethod + const FwdNone + const FwdRequest + const FwdStale + const FwdURIMiss + const FwdVaryMiss + type KeyConfig struct + AcceptEncoding []string + Cookies []string + Headers []string + MaxVariants int + MaxVaryHeaders int + NormalizePath bool + QueryDrop []string + QueryKeep []string + QuerySort bool + Vary VaryMode + VaryAllow []string + type LimiterConfig struct + MaxConcurrent int + MaxPerHost int + MaxPerPartition int + MaxQueue int + MaxQueueWait time.Duration + MaxUpload int + ReserveForeground int + type LimitsConfig struct + MaxGroupBytes int + MaxGroups int + MaxKeyedHeaderBytes int + MaxPathBytes int + MaxQueryBytes int + MaxQueryParams int + type MissRateConfig struct + Disable bool + MinMisses int + MinRatio float64 + Throttle bool + TopK int + Window time.Duration + type Mode uint8 + const ModeBypass + const ModeNormal + const ModeStaleOnError + type NegativeConfig struct + Disable bool + TTL time.Duration + type Observer interface + Observe func(Event) + type Origin interface + Fetch func(ctx context.Context, req *Request) (*Response, error) + type OriginError struct + Err error + func (e *OriginError) Error() string + func (e *OriginError) Is(target error) bool + func (e *OriginError) Unwrap() error + type OriginFunc func(ctx context.Context, req *Request) (*Response, error) + func (f OriginFunc) Fetch(ctx context.Context, req *Request) (*Response, error) + type Purge struct + All bool + Eager bool + Groups []string + Mode PurgeMode + Origin string + URLs []string + type PurgeMode uint8 + const PurgeHard + const PurgeSoft + type Request struct + Body io.ReadCloser + Header http.Header + Host string + Method string + Path string + RawQuery string + Scheme string + type RequestError struct + Reason string + func (e *RequestError) Error() string + func (e *RequestError) Unwrap() error + type Response struct + Body io.ReadCloser + Cache CacheInfo + Header http.Header + StatusCode int + type RetryError struct + After time.Duration + Err error + func (e *RetryError) Error() string + func (e *RetryError) Unwrap() error + type StaleReason uint8 + const StaleCircuitOpen + const StaleCoalesceTimeout + const StaleIfError + const StaleNone + const StaleShed + const StaleWhileRevalidate + type StorableConfig struct + MaxObjectBytes int64 + Statuses []int + StreamTypes []string + StripSetCookie bool + type TimeoutsConfig struct + Background time.Duration + Origin time.Duration + Store time.Duration + StreamIdle time.Duration + type VaryMode uint8 + const VaryAuto + const VaryStrict + type WarmConfig struct + Concurrency int + type WarmStats struct + Failed int + Fetched int + NotStored int + Skipped int