config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 2 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 {
	// Batch is the size of the string slices fed into input channel for
	// verification.
	Batch int

	// DataSources are IDs of DataSources that are important for
	// user. Normally only one "the best" reusult returns. If user gives
	// preferred sources, then matches from these sources are also
	// returned.
	DataSources []int

	// Format determins the output. It can be either JSON or CSV.
	Format gnfmt.Format

	// Jobs is the number of verification jobs to run in parallel.
	Jobs int

	// NamesNumThreshold the number of names after which POST gets redirected
	// to GET.
	NamesNumThreshold int

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

	// VerifierURL URL for gnames verification service. It only needs to
	// be changed if user sets local version of gnames.
	VerifierURL string

	// WithAllMatches flag; if true, results include all matches per source,
	// not only the best match.
	WithAllMatches bool

	// WithCapitalization flag; if true, the first rune of the name-string
	// will be capitalized when appropriate.
	WithCapitalization bool

	// WithSpeciesGroup flag; it is true, verification tries to search not only
	// for the given species name, but also for its species group. It means that
	// searching for "Aus bus" will also search for "Aus bus bus" and vice versa.
	// This function reflects existence of autononyms in botanical code, and
	// coordinated names in zoological code.
	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

func New(opts ...Option) Config

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

type Option

type Option func(cnf *Config)

Option is a type of all options for Config.

func OptDataSources

func OptDataSources(srs []int) Option

OptDataSources set list of preferred sources.

func OptFormat

func OptFormat(f gnfmt.Format) Option

OptFormat sets output format

func OptJobs

func OptJobs(i int) Option

OptJobs sets number of jobs to run in parallel.

func OptNamesNumThreshold

func OptNamesNumThreshold(i int) Option

OptNamesNumThreshold sets number of names after which there is no redirect from POST to GET.

func OptNsqdContainsFilter added in v0.7.2

func OptNsqdContainsFilter(s string) Option

OptNsqdContainsFilter provides a filter for logs sent to NSQ service.

func OptNsqdRegexFilter added in v0.7.2

func OptNsqdRegexFilter(s string) Option

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

func OptNsqdTCPAddress added in v0.7.2

func OptNsqdTCPAddress(s string) Option

OptNsqdTCPAddress provides a URL to NSQ messanging service.

func OptVerifierURL

func OptVerifierURL(s string) Option

OptVerifierURL sets URL of the verification resource.

func OptWithAllMatches

func OptWithAllMatches(b bool) Option

OptWithAllMatches sets WithAllMatches flag.

func OptWithCapitalization

func OptWithCapitalization(b bool) Option

OptWithCapitalization sets WithCapitalization field.

func OptWithSpeciesGroup added in v0.9.5

func OptWithSpeciesGroup(b bool) Option

OptWithSpeciesGroup sets WithSpeciesGroup field.

func OptWithWebLogs added in v0.7.0

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