config

package
v0.11.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultListenAddress              = "127.0.0.1:8080"
	DefaultRedisAddr                  = "127.0.0.1:6379"
	DefaultQueue                      = "default"
	DefaultConcurrency                = 10
	DefaultJobsPath                   = "/__jobs"
	DefaultTaskRetention              = Duration(1 * time.Hour)
	DefaultUpstreamTimeout            = Duration(5 * time.Minute)
	DefaultMaxBodySize          int64 = 10 << 20 // 10MB
	DefaultDirectProxyThreshold int64 = 10 << 20
	DefaultCacheMaxEntries            = 10000
	DefaultCacheRedisKeyPrefix        = "proxq:"
	DefaultCacheTTL                   = Duration(5 * time.Minute)
)

Variables

View Source
var (
	ErrNoUpstreams = errors.New(
		"at least one upstream required",
	)
	ErrRootWithMultipleUpstreams = errors.New(
		"root prefix \"/\" only allowed with a single upstream",
	)
	ErrNestedPrefixes = errors.New(
		"upstream prefixes must not overlap",
	)
	ErrPrefixConflictsWithJobsPath = errors.New(
		"upstream prefix conflicts with jobs path",
	)
)

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	Mode           string   `yaml:"mode"`
	TTL            Duration `yaml:"ttl"`
	MaxEntries     int      `yaml:"maxEntries"`
	RedisKeyPrefix string   `yaml:"redisKeyPrefix"`
}

type CacheMode

type CacheMode = string
const (
	CacheModeNone   CacheMode = "none"
	CacheModeMemory CacheMode = "memory"
	CacheModeRedis  CacheMode = "redis"
)

type Config

type Config struct {
	ListenAddress string      `yaml:"listenAddress"`
	Redis         RedisConfig `yaml:"redis"`
	Queue         string      `yaml:"queue"`
	Concurrency   int         `yaml:"concurrency"`
	JobsPath      string      `yaml:"jobsPath"`
	TaskRetention Duration    `yaml:"taskRetention"`
	Cache         CacheConfig `yaml:"cache"`
	Upstreams     []Upstream  `yaml:"upstreams"`
}

func Parse

func Parse(path string) (Config, error)

type DirectProxyMode

type DirectProxyMode = string
const (
	DirectProxyModeProxy    DirectProxyMode = "proxy"
	DirectProxyModeRedirect DirectProxyMode = "redirect"
)

type Duration

type Duration time.Duration

func (Duration) Std

func (d Duration) Std() time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(
	value *yaml.Node,
) error

type PathFilterConfig

type PathFilterConfig struct {
	Mode     string   `yaml:"mode"`
	Patterns []string `yaml:"patterns"`
}

type PathFilterMode

type PathFilterMode = string
const (
	PathFilterModeBlacklist PathFilterMode = "blacklist"
	PathFilterModeWhitelist PathFilterMode = "whitelist"
)

type RedisConfig

type RedisConfig struct {
	Addr string `yaml:"addr"`
	// Username selects a Redis ACL user. Empty authenticates as the default
	// user with Password alone.
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	DB       int    `yaml:"db"`
}

type Upstream

type Upstream struct {
	Prefix                 string           `yaml:"prefix"`
	URL                    string           `yaml:"url"`
	Timeout                Duration         `yaml:"timeout"`
	MaxRetries             int              `yaml:"maxRetries"`
	RetryDelay             Duration         `yaml:"retryDelay"`
	MaxBodySize            int64            `yaml:"maxBodySize"`
	DirectProxyThreshold   int64            `yaml:"directProxyThreshold"` //nolint:lll
	DirectProxyMode        string           `yaml:"directProxyMode"`
	CacheKeyExcludeHeaders []string         `yaml:"cacheKeyExcludeHeaders"` //nolint:lll
	PathFilter             PathFilterConfig `yaml:"pathFilter"`

	CompiledPatterns []*regexp.Regexp `yaml:"-"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL