v1.0.1 Latest Latest

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

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 5 Imported by: 0



package config contains information needed to run gnmatcher project.



This section is empty.


This section is empty.


This section is empty.


type Config

type Config struct {
	// CacheDir is the main directory for gnmatcher files. It contains
	// bloom filters levenshtein automata trees, key-value stores etc.
	CacheDir string

	// DataSources can limit matching to provided dataSources. Such approach
	// helps to provide more accurate matches. For example if a searched name
	// `Aus bus bus` exists somewhere but not in a data-source with ID 5,
	// however this data-source contains 'Aus bus'. Setting DataSources to
	// []int{5} will ignore results from other sources, and will set
	// partial match, finding 'Aus bus' as with a MatchType of PartialMatch.
	DataSources []int

	// JobsNum is the number of jobs to run in parallel
	JobsNum int

	// MaxEditDist is the maximal allowed edit distance for levenshtein automata.
	// The number cannot exceed 2, default number is 1. The speed of execution
	// slows down dramatically with the MaxEditDist > 1.
	MaxEditDist int

	// PgDB the database name where gnames data is located.
	PgDB string

	// PgHost is a hostname for the PostgreSQL server.
	PgHost string

	// PgPass password to access PostgreSQL server.
	PgPass string

	// PgPort is the port of PostgreSQL server.
	PgPort int

	// PgUser is the user for the database.
	PgUser string

	// NsqdTCPAddress provides an address to the NSQ messenger TCP service. If
	// this value is set and valid, the web logs will be published to the NSQ.
	// The option is ignored if `Port` is not set.
	// If WithWebLogs option is set to `false`, but `NsqdTCPAddress` is set to a
	// valid URL, the logs will be sent to the NSQ messanging service, but they
	// wil not appear as STRERR output.
	// Example: ``
	NsqdTCPAddress string

	// NsqdContainsFilter logs should match the filter to be sent to NSQ
	// service.
	// Examples:
	// "api" - logs should contain "api"
	// "!api" - logs should not contain "apim
	NsqdContainsFilter string

	// NsqdRegexFilter logs should match the regular expression to be sent to
	// NSQ service.
	// Example: `api\/v(0|1)`
	NsqdRegexFilter *regexp.Regexp

	// WithSpeciesGroup is true when searching for "Aus bus" also searches for
	// "Aus bus bus".
	WithSpeciesGroup bool

	// WithWebLogs flag enables logs when running web-service. This flag is
	// ignored if `Port` value is not set.
	WithWebLogs bool

Config collects and stores external configuration data.

func New added in v0.6.1

func New(opts ...Option) Config

New is a Config constructor that takes external options to update default values to external ones.

func (Config) FiltersDir

func (cfg Config) FiltersDir() string

FiltersDir returns path where to dump/restore serialized bloom filters.

func (Config) StemsDir

func (cfg Config) StemsDir() string

StemsDir returns path where stems key-value store is located.

func (Config) TrieDir

func (cfg Config) TrieDir() string

TrieDir returns path where to dump/restore serialized trie.

func (Config) VirusDir added in v0.7.0

func (cfg Config) VirusDir() string

VirusDir returns path to cache virus matching data.

type Option

type Option func(cfg *Config)

Option is a type of all options for Config.

func OptCacheDir added in v0.6.0

func OptCacheDir(s string) Option

OptCacheDir sets a directory for key-value stores and temporary files.

func OptDataSources added in v0.9.9

func OptDataSources(ints []int) Option

OptDataSources sets ids to use for matching.

func OptJobsNum

func OptJobsNum(i int) Option

OptJobsNum sets the number of jobs to run in parallel

func OptMaxEditDist

func OptMaxEditDist(i int) Option

OptMaxEditDist sets maximal possible edit distance for fuzzy matching of stemmed canonical forms.

func OptNsqdContainsFilter added in v0.7.4

func OptNsqdContainsFilter(s string) Option

OptNsqdContainsFilter provides a filter for logs sent to NSQ service.

func OptNsqdRegexFilter added in v0.7.4

func OptNsqdRegexFilter(s string) Option

OptNsqdRegexFilter provides a regular expression filter for logs sent to NSQ service.

func OptNsqdTCPAddress added in v0.7.4

func OptNsqdTCPAddress(s string) Option

OptNsqdTCPAddress provides an address of NSQ messanging service.

func OptPgDB

func OptPgDB(s string) Option

OptPgDB sets the name of gnames database

func OptPgHost

func OptPgHost(s string) Option

OptPgHost sets the host of gnames database

func OptPgPass

func OptPgPass(s string) Option

OptPgPass sets the password to access gnnames database

func OptPgPort

func OptPgPort(i int) Option

OptPgPort sets the port for gnames database

func OptPgUser

func OptPgUser(s string) Option

OptPgUser sets the user of gnnames database

func OptWithSpeciesGroup added in v0.9.6

func OptWithSpeciesGroup(b bool) Option

OptWithSpeciesGroup sets the WithSpeciesGroup field

func OptWithWebLogs added in v0.6.1

func OptWithWebLogs(b bool) Option

OptWithWebLogs sets the WithWebLogs field.

Jump to

Keyboard shortcuts

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