config

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 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 NewInfo

func NewInfo() []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
	// that means that badger will run in memory only
	Persist bool `koanf:"persist"`
}

type Cache

type Cache struct {
	Type   string
	TTL    TTL
	Badger Badger
	Redis  Redis
}

type Category

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

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 EngineRanking

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

type Proxy added in v0.13.0

type Proxy struct {
	Salt     string
	Timeouts ProxyTimeouts
}

type ProxyTimeouts added in v0.13.0

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

type Ranking

type Ranking 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]EngineRanking `koanf:"engines"`
}

func EmptyRanking added in v0.10.0

func EmptyRanking() Ranking

func NewRanking

func NewRanking() Ranking

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]ReaderEngine `koanf:"engines"`
	Ranking  Ranking                 `koanf:"ranking"`
	RTimings ReaderTimings           `koanf:"timings"`
}

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

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 ReaderEngine

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

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

type ReaderProxy added in v0.13.0

type ReaderProxy struct {
	Salt     string              `koanf:"salt"`
	Timeouts ReaderProxyTimeouts `koanf:"timeouts"`
}

type ReaderProxyTimeouts added in v0.13.0

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

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, comma separated (wildcards allowed) and converted into slice
	FrontendUrls string `koanf:"frontendurls"`
	// cache settings
	Cache ReaderCache `koanf:"cache"`
	// salt used for image proxy
	Proxy ReaderProxy `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
	// to disable caching set conf.Cache.Type to "none"
	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 ReaderTimings

type ReaderTimings struct {
	PreferredTimeout        uint `koanf:"preferredtimeout"`
	PreferredTimeoutResults int  `koanf:"preferredtimeoutresults"`
	AdditionalTimeout       uint `koanf:"additionaltimeout"`
	HardTimeout             uint `koanf:"hardtimeout"`
	Timeout                 uint `koanf:"timeout"`
	PageTimeout             uint `koanf:"pagetimeout"`
	Delay                   uint `koanf:"delay"`
	RandomDelay             uint `koanf:"randomdelay"`
	Parallelism             int  `koanf:"parallelism"`
}

ReaderTimings is format in which the config is read from the config file in miliseconds

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  string
	Port         int
	FrontendUrls []string
	Cache        Cache
	Proxy        Proxy
}

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 {
	Time        time.Duration
	RefreshTime time.Duration
}

type Timings

type Timings struct {
	// preferred timeout if enough results are found
	PreferredTimeout time.Duration
	// number of results which if not met will trigger the additional timeout
	PreferredTimeoutResults int
	// additional timeout if not enough results are found (delay after which the number of results is checked)
	AdditionalTimeout time.Duration
	// hard timeout after which the search is forcefully stopped
	HardTimeout time.Duration
	// colly settings
	Timeout     time.Duration
	PageTimeout time.Duration
	Delay       time.Duration
	RandomDelay time.Duration
	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()

Jump to

Keyboard shortcuts

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