category

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category added in v0.32.0

type Category struct {
	Engines                  []engines.Name
	RequiredEngines          []engines.Name
	RequiredByOriginEngines  []engines.Name
	PreferredEngines         []engines.Name
	PreferredByOriginEngines []engines.Name
	Ranking                  Ranking
	Timings                  Timings
}

func Base64ToCategoryType added in v0.32.0

func Base64ToCategoryType(b64 string) (Category, error)

func (Category) ContainsDisabledEngines added in v0.32.0

func (c Category) ContainsDisabledEngines(disabledEngines []engines.Name) bool

Returns true if the category contains any disabled engines. Otherwise, returns false.

type CategoryJSON added in v0.32.0

type CategoryJSON struct {
	Engines map[string]EngineJSON `koanf:"engines"`
	Ranking RankingJSON           `koanf:"ranking"`
	Timings TimingsJSON           `koanf:"timings"`
}

CategoryJSON is format in which the config is passed from the user.

func Base64ToCategoryJSON added in v0.32.0

func Base64ToCategoryJSON(b64 string) (CategoryJSON, error)

func (CategoryJSON) ToCategoryType added in v0.32.0

func (cj CategoryJSON) ToCategoryType() (Category, error)

Converts the category JSON into a more program friendly category type. Returns an error if any issues occur during the conversion.

type EngineJSON added in v0.32.0

type EngineJSON struct {
	// If false, the engine will not be used and other options will be ignored.
	// This adds the engine to engines slice during conversion.
	Enabled bool `koanf:"enabled"`
	// If true, the engine will be awaited unless the hard timeout is reached.
	// This adds the engine to required engines slice during conversion.
	Required bool `koanf:"required"`
	// If true, the fastest engine that has this engine in "Origins" will be awaited unless the hard timeout is reached.
	// This means that we want to get results from this engine or any engine that has this engine in "Origins", whichever responds the fastest.
	// This adds the engine to required engines by origin slice during conversion.
	RequiredByOrigin bool `koanf:"requiredbyorigin"`
	// If true, the engine will be awaited unless the preferred timeout is reached.
	// This adds the engine to preferred engines slice during conversion.
	Preferred bool `koanf:"preferred"`
	// If true, the fastest engine that has this engine in "Origins" will be awaited unless the preferred timeout is reached.
	// This means that we want to get results from this engine or any engine that has this engine in "Origins", whichever responds the fastest.
	// This adds the engine to preferred by origin slice during conversion.
	PreferredByOrigin bool `koanf:"preferredbyorigin"`
}

EngineJSON is format in which the config is passed from the user.

type EngineRanking added in v0.32.0

type EngineRanking struct {
	Mul float64
	Add float64
}

type EngineRankingJSON added in v0.32.0

type EngineRankingJSON struct {
	Mul float64 `koanf:"mul"`
	Add float64 `koanf:"add"`
}

type Ranking added in v0.32.0

type Ranking struct {
	// The exponent, multiplier and addition used on the rank itself.
	RankExp float64
	RankMul float64
	RankAdd float64
	// The multiplier and addition used on the rank score (number calculated from dividing 100 with the rank + above variables applied).
	RankScoreMul float64
	RankScoreAdd float64
	// The multiplier and addition used on the number of times the result was returned.
	TimesReturnedMul float64
	TimesReturnedAdd float64
	// The multiplier and addition used on the times returned score (number calculated from doing log(timesReturnedNum + above variables applied)).
	TimesReturnedScoreMul float64
	TimesReturnedScoreAdd float64
	// Multipliers and additions for each engine, applied to the rank score.
	Engines map[engines.Name]EngineRanking
}

type RankingJSON added in v0.32.0

type RankingJSON struct {
	// The exponent, multiplier and addition used on the rank itself.
	RankExp float64 `koanf:"rankexp"`
	RankMul float64 `koanf:"rankmul"`
	RankAdd float64 `koanf:"rankconst"`
	// The multiplier and addition used on the rank score (number calculated from dividing 100 with the rank + above variables applied).
	RankScoreMul float64 `koanf:"rankscoremul"`
	RankScoreAdd float64 `koanf:"rankscoreadd"`
	// The multiplier and addition used on the number of times the result was returned.
	TimesReturnedMul float64 `koanf:"timesreturnedmul"`
	TimesReturnedAdd float64 `koanf:"timesreturnedadd"`
	// The multiplier and addition used on the times returned score (number calculated from doing log(timesReturnedNum + above variables applied)).
	TimesReturnedScoreMul float64 `koanf:"timesreturnedscoremul"`
	TimesReturnedScoreAdd float64 `koanf:"timesreturnedscoreadd"`
	// Multipliers and additions for each engine, applied to the rank score.
	Engines map[string]EngineRankingJSON `koanf:"engines"`
}

RankingJSON is format in which the config is passed from the user.

type Timings added in v0.32.0

type Timings struct {
	// Maximum amount of time to wait for the PreferredEngines (or ByOrigin) to respond.
	// If the search is still waiting for the RequiredEngines (or ByOrigin) after this time, the search will continue.
	PreferredTimeout time.Duration
	// Hard timeout after which the search is forcefully stopped (even if the engines didn't respond).
	HardTimeout time.Duration
}

type TimingsJSON added in v0.32.0

type TimingsJSON struct {
	// Maximum amount of time to wait for the PreferredEngines (or ByOrigin) to respond.
	// If the search is still waiting for the RequiredEngines (or ByOrigin) after this time, the search will continue.
	PreferredTimeout string `koanf:"preferredtimeout"`
	// Hard timeout after which the search is forcefully stopped (even if the engines didn't respond).
	HardTimeout string `koanf:"hardtimeout"`
}

TimingsJSON is format in which the config is passed from the user. In <number><unit> format. Example: 1s, 1m, 1h, 1d, 1w, 1M, 1y. If unit is not specified, it is assumed to be milliseconds.

Jump to

Keyboard shortcuts

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