config

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port is the REST service port
	Port int

	// CacheDir is a directory to keep cached data.
	CacheDir string

	// JobsNum is the number of processes to run concurrently.
	JobsNum int

	// MaxEditDist is the the muximum number of Levenschein edits before
	// aborging a fuzzy matching.
	MaxEditDist int

	// MatcherURL is the URL where GNmatcher REST service resides.
	// It is used to get source-agnostic name-matching.
	MatcherURL string

	// PgDB is the name of GNames database.
	PgDB string

	// PgHost is the domain name or IP address of PostgreSQL service.
	PgHost string

	// PgPass is the password for the PostgreSQL user.
	PgPass string

	// PgPort is the port used by PostgreSQL service.
	PgPort int

	// PgUser is the PostgreSQL user with access to GNames 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: `127.0.0.1:4150`
	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 "api"
	NsqdContainsFilter string

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

	// 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.5.0

func New(opts ...Option) Config

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

func (Config) FiltersDir

func (cnf Config) FiltersDir() string

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

func (Config) StemsDir

func (cnf Config) StemsDir() string

StemsDir returns path where stems key-value store is located

func (Config) TrieDir

func (cnf Config) TrieDir() string

TrieDir returns path where to dump/restore serialized trie.

type Option

type Option func(cnf *Config)

Option is a type of all options for Config.

func OptGNPort

func OptGNPort(i int) Option

OptGNPort sets port for gnames HTTP service.

func OptJobsNum

func OptJobsNum(i int) Option

OptJobsNum sets number of concurrent jobs to run for parallel tasks.

func OptMatcherURL

func OptMatcherURL(s string) Option

OptMatcherURL sets the name of gnames database

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.6.4

func OptNsqdContainsFilter(s string) Option

OptNsqdContainsFilter provides a filter for logs sent to NSQ service.

func OptNsqdRegexFilter added in v0.6.4

func OptNsqdRegexFilter(s string) Option

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

func OptNsqdTCPAddress added in v0.6.4

func OptNsqdTCPAddress(s string) Option

OptNsqdTCPAddress provides a URL to 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 OptWithWebLogs added in v0.6.0

func OptWithWebLogs(b bool) Option

OptWithWebLogs sets the WithWebLogs field.

func OptWorkDir

func OptWorkDir(s string) Option

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

Jump to

Keyboard shortcuts

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