config

package
v0.32.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// Can be "none", "redis" or "dynamodb".
	Type string
	// Prefix to use for cache keys.
	KeyPrefix string
	// Has no effect if type is "none".
	TTL TTL
	// Redis specific settings.
	Redis Redis
	// DynamoDB specific settings.
	DynamoDB DynamoDB
}

type Config

type Config struct {
	Server   Server
	Engines  EngineConfig
	Exchange Exchange
}

func New

func New() Config

func (*Config) Load

func (c *Config) Load(configPath string)

type DynamoDB added in v0.25.0

type DynamoDB struct {
	// Set to "global" or leave empty for a DynamoDB global table.
	Region string `koanf:"region"`
	Table  string `koanf:"table"`
	// Endpoint is used for local testing.
	Endpoint string `koanf:"endpoint"`
}

type EngineConfig added in v0.32.0

type EngineConfig struct {
	NoWeb         []engines.Name
	NoImages      []engines.Name
	NoSuggestions []engines.Name
}

Slices of disabled engines for each search type, by default these are empty.

type Exchange added in v0.26.0

type Exchange struct {
	BaseCurrency currency.Currency
	Engines      []engines.Name
	Timings      ExchangeTimings
}

type ExchangeTimings added in v0.26.0

type ExchangeTimings struct {
	// Hard timeout after which the search is forcefully stopped (even if the engines didn't respond).
	HardTimeout time.Duration
}

type ImageProxy

type ImageProxy struct {
	SecretKey string
	Timeout   time.Duration
}

type ReaderCache

type ReaderCache struct {
	// Can be "none", "redis" or "dynamodb".
	Type string `koanf:"type"`
	// Prefix to use for cache keys.
	KeyPrefix string `koanf:"keyprefix"`
	// Has no effect if type is "none".
	TTL ReaderTTL `koanf:"ttl"`
	// Redis specific settings.
	Redis Redis `koanf:"redis"`
	// DynamoDB specific settings.
	DynamoDB DynamoDB `koanf:"dynamodb"`
}

ReaderCache is format in which the config is read from the config file and environment variables.

type ReaderConfig

type ReaderConfig struct {
	Server    ReaderServer                  `koanf:"server"`
	REngines  map[string]ReaderEngineConfig `koanf:"engines"`
	RExchange ReaderExchange                `koanf:"exchange"`
}

ReaderConfig is format in which the config is read from the config file and environment variables.

type ReaderEngineConfig added in v0.32.0

type ReaderEngineConfig struct {
	NoWeb         bool `koanf:"noweb"`         // Whether this engine is disallowed to do web searches.
	NoImages      bool `koanf:"noimages"`      // Whether this engine is disallowed to do image searches.
	NoSuggestions bool `koanf:"nosuggestions"` // Whether this engine is disallowed to do suggestion searches.
}

ReaderEngineConfig is format in which the config is read from the config file and environment variables. Used to disable certain search types for an engine. By default, all types are enabled.

type ReaderExchange added in v0.26.0

type ReaderExchange struct {
	BaseCurrency string                          `koanf:"basecurrency"`
	REngines     map[string]ReaderExchangeEngine `koanf:"engines"`
	RTimings     ReaderExchangeTimings           `koanf:"timings"`
}

ReaderCategory is format in which the config is read from the config file and environment variables.

type ReaderExchangeEngine added in v0.26.0

type ReaderExchangeEngine struct {
	// If false, the engine will not be used.
	Enabled bool `koanf:"enabled"`
}

ReaderEngine is format in which the config is read from the config file and environment variables.

type ReaderExchangeTimings added in v0.26.0

type ReaderExchangeTimings struct {
	// Hard timeout after which the search is forcefully stopped (even if the engines didn't respond).
	HardTimeout string `koanf:"hardtimeout"`
}

ReaderTimings is format in which the config is read from the config file and environment variables. In <number><unit> format. Example: 1s, 1m, 1h, 1d, 1w, 1M, 1y. If unit is not specified, it is assumed to be milliseconds.

type ReaderImageProxy

type ReaderImageProxy struct {
	SecretKey string `koanf:"secretkey"`
	Timeout   string `koanf:"timeout"`
}

ReaderProxy is format in which the config is read from the config file and environment variables. In <number><unit> format. Example: 1s, 1m, 1h, 1d, 1w, 1M, 1y. If unit is not specified, it is assumed to be milliseconds.

type ReaderServer

type ReaderServer struct {
	// Environment in which the server is running (normal or lambda).
	Environment string `koanf:"environment"`
	// Port on which the API server listens.
	Port int `koanf:"port"`
	// URLs used for CORS (wildcards allowed).
	// Comma separated.
	FrontendUrls string `koanf:"frontendurls"`
	// Cache settings.
	Cache ReaderCache `koanf:"cache"`
	// Image proxy settings.
	ImageProxy ReaderImageProxy `koanf:"imageproxy"`
}

ReaderServer is format in which the config is read from the config file and environment variables.

type ReaderTTL

type ReaderTTL struct {
	// How long to store the currencies in cache.
	// Setting this to 0 caches the currencies forever.
	Currencies string `koanf:"currencies"`
}

ReaderTTL is format in which the config is read from the config file and environment variables. In <number><unit> format. Example: 1s, 1m, 1h, 1d, 1w, 1M, 1y. If unit is not specified, it is assumed to be milliseconds.

type Redis

type Redis struct {
	Host     string `koanf:"host"`
	Port     uint16 `koanf:"port"`
	Password string `koanf:"password"`
	Database uint8  `koanf:"database"`
}

type Server

type Server struct {
	// Environment in which the server is running (normal or lambda).
	Environment string
	// Port on which the API server listens.
	Port int
	// URLs used for CORS (wildcards allowed).
	FrontendUrls []string
	// Cache settings.
	Cache Cache
	// Image proxy settings.
	ImageProxy ImageProxy
}

type TTL

type TTL struct {
	// How long to store the currencies in cache.
	// Setting this to 0 caches the currencies forever.
	Currencies time.Duration
}

Jump to

Keyboard shortcuts

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