config

package
v0.17.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultLocale string = "en_US"

Variables

This section is empty.

Functions

func NewAllEnabled

func NewAllEnabled() []engines.Name

func NewGeneral added in v0.10.0

func NewGeneral() []engines.Name

func NewImage added in v0.11.0

func NewImage() []engines.Name

func NewQuick added in v0.17.0

func NewQuick() []engines.Name

func NewScience added in v0.10.0

func NewScience() []engines.Name

func NewSettings

func NewSettings() map[engines.Name]Settings

Types

type Badger added in v0.10.0

type Badger struct {
	// Setting this to false will result in badger not persisting the cache to disk making it run "in-memory"
	Persist bool `koanf:"persist"`
}

type Cache

type Cache struct {
	// Can be "none", "badger" or "redis"
	Type string
	// Has no effect if type is "none"
	TTL TTL
	// Badger specific settings
	Badger Badger
	// Redis specific settings
	Redis Redis
}

type Category

type Category struct {
	Engines []engines.Name
	Ranking CategoryRanking
	Timings CategoryTimings
}

type CategoryEngineRanking added in v0.17.0

type CategoryEngineRanking struct {
	Mul   float64 `koanf:"mul"`
	Const float64 `koanf:"const"`
}

type CategoryRanking added in v0.17.0

type CategoryRanking struct {
	REXP    float64                          `koanf:"rexp"`
	A       float64                          `koanf:"a"`
	B       float64                          `koanf:"b"`
	C       float64                          `koanf:"c"`
	D       float64                          `koanf:"d"`
	TRA     float64                          `koanf:"tra"`
	TRB     float64                          `koanf:"trb"`
	TRC     float64                          `koanf:"trc"`
	TRD     float64                          `koanf:"trd"`
	Engines map[string]CategoryEngineRanking `koanf:"engines"`
}

func EmptyRanking added in v0.10.0

func EmptyRanking() CategoryRanking

func NewRanking

func NewRanking() CategoryRanking

type CategoryTimings added in v0.17.0

type CategoryTimings struct {
	// Minimum amount of time to wait before starting to check the number of results
	// Search will wait for at least this amount of time (unless all engines respond)
	PreferredTimeoutMin time.Duration
	// Maximum amount of time to wait until the number of results is satisfactory
	// Search will wait for at most this amount of time (unless all engines respond or the preferred number of results is found)
	PreferredTimeoutMax time.Duration
	// Preferred number of results to find
	PreferredResultsNumber int
	// Time of the steps for checking if the number of results is satisfactory
	StepTime time.Duration
	// Minimum number of results required after the maximum preferred time
	// If this number isn't met, the search will continue after the maximum preferred time
	MinimumResultsNumber int
	// Hard timeout after which the search is forcefully stopped (even if the engines didn't respond)
	HardTimeout time.Duration
	// Colly delay
	Delay time.Duration
	// Colly random delay
	RandomDelay time.Duration
	// Colly parallelism
	Parallelism int
}

Delegates Timeout, PageTimeout to colly.Collector.SetRequestTimeout(); Note: See https://github.com/gocolly/colly/issues/644 Delegates Delay, RandomDelay, Parallelism to colly.Collector.Limit()

type Config

type Config struct {
	Server     Server
	Categories map[category.Name]Category
	Settings   map[engines.Name]Settings
}

func New

func New() Config

func (*Config) Load

func (c *Config) Load(dataDirPath string)

passed as pointer since config is modified

type ImageProxy added in v0.17.0

type ImageProxy struct {
	Salt     string
	Timeouts ImageProxyTimeouts
}

type ImageProxyTimeouts added in v0.17.0

type ImageProxyTimeouts struct {
	Dial         time.Duration
	KeepAlive    time.Duration
	TLSHandshake time.Duration
}

type ReaderCache added in v0.10.0

type ReaderCache struct {
	// Can be "none", "badger" or "redis"
	Type string `koanf:"type"`
	// Has no effect if type is "none"
	TTL ReaderTTL `koanf:"ttl"`
	// Badger specific settings
	Badger Badger `koanf:"badger"`
	// Redis specific settings
	Redis Redis `koanf:"redis"`
}

ReaderCache is format in which the config is read from the config file

type ReaderCategory

type ReaderCategory struct {
	REngines map[string]ReaderCategoryEngine `koanf:"engines"`
	Ranking  CategoryRanking                 `koanf:"ranking"`
	RTimings ReaderCategoryTimings           `koanf:"timings"`
}

ReaderCategory is format in which the config is read from the config file

type ReaderCategoryEngine added in v0.17.0

type ReaderCategoryEngine struct {
	Enabled bool `koanf:"enabled"`
}

ReaderEngine is format in which the config is read from the config file

type ReaderCategoryTimings added in v0.17.0

type ReaderCategoryTimings struct {
	// Minimum amount of time to wait before starting to check the number of results
	// Search will wait for at least this amount of time (unless all engines respond)
	PreferredTimeoutMin string `koanf:"preferredtimeoutmin"`
	// Maximum amount of time to wait until the number of results is satisfactory
	// Search will wait for at most this amount of time (unless all engines respond or the preferred number of results is found)
	PreferredTimeoutMax string `koanf:"preferredtimeoutmax"`
	// Preferred number of results to find
	PreferredResultsNumber int `koanf:"preferredresultsnumber"`
	// Time of the steps for checking if the number of results is satisfactory
	StepTime string `koanf:"steptime"`
	// Minimum number of results required after the maximum preferred time
	// If this number isn't met, the search will continue after the maximum preferred time
	MinimumResultsNumber int `koanf:"minimumresultsnumber"`
	// Hard timeout after which the search is forcefully stopped (even if the engines didn't respond)
	HardTimeout string `koanf:"hardtimeout"`
	// Colly delay
	Delay string `koanf:"delay"`
	// Colly random delay
	RandomDelay string `koanf:"randomdelay"`
	// Colly parallelism
	Parallelism int `koanf:"parallelism"`
}

ReaderTimings is format in which the config is read from the config file In <number><unit> format Example: 1s, 1m, 1h, 1d, 1w, 1M, 1y If unit is not specified, it is assumed to be milliseconds Delegates Timeout, PageTimeout to colly.Collector.SetRequestTimeout(); Note: See https://github.com/gocolly/colly/issues/644 Delegates Delay, RandomDelay, Parallelism to colly.Collector.Limit()

type ReaderConfig

type ReaderConfig struct {
	Server      ReaderServer                     `koanf:"server"`
	RCategories map[category.Name]ReaderCategory `koanf:"categories"`
	Settings    map[string]Settings              `koanf:"settings"`
}

ReaderConfig is format in which the config is read from the config file

type ReaderImageProxy added in v0.17.0

type ReaderImageProxy struct {
	Salt     string                   `koanf:"salt"`
	Timeouts ReaderImageProxyTimeouts `koanf:"timeouts"`
}

ReaderProxy is format in which the config is read from the config file

type ReaderImageProxyTimeouts added in v0.17.0

type ReaderImageProxyTimeouts struct {
	Dial         string `koanf:"dial"`
	KeepAlive    string `koanf:"keepalive"`
	TLSHandshake string `koanf:"tlshandshake"`
}

ReaderProxyTimeouts is format in which the config is read from the config file 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 added in v0.10.0

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
	Proxy ReaderImageProxy `koanf:"proxy"`
}

ReaderServer is format in which the config is read from the config file

type ReaderTTL added in v0.10.0

type ReaderTTL struct {
	// how long to store the results in cache
	// setting this to 0 caches the results forever
	Time string `koanf:"time"`
	// if the remaining TTL when retrieving from cache is less than this, update the cache entry and reset the TTL
	// setting this to 0 disables this feature
	// setting this to the same value (or higher) as Results will update the cache entry every time
	RefreshTime string `koanf:"refreshtime"`
}

ReaderTTL is format in which the config is read from the config file 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
	Proxy ImageProxy
}

type Settings

type Settings struct {
	RequestedResultsPerPage int      `koanf:"requestedresults"`
	Shortcut                string   `koanf:"shortcut"`
	Proxies                 []string `koanf:"proxies"`
}

type TTL added in v0.10.0

type TTL struct {
	// How long to store the results in cache
	// Setting this to 0 caches the results forever
	Time time.Duration
	// If the remaining TTL when retrieving from cache is less than this, update the cache entry and reset the TTL
	// Setting this to 0 disables this feature
	// Setting this to the same value (or higher) as Results will update the cache entry every time
	RefreshTime time.Duration
}

Jump to

Keyboard shortcuts

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