config

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: MIT Imports: 1 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 {
	// Format determins the output. It can be either JSON or CSV.
	Format gnfmt.Format

	// PreferredOnly hides BestResult if the user wants to see only
	// preferred results.
	PreferredOnly bool

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

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

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

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

	// Batch is the size of the string slices fed into input channel for
	// verification.
	Batch int

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

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 OptPreferredOnly

func OptPreferredOnly(b bool) Option

OptPreferredOnly sets PreferredOnly field. If it is true output only contains results from preferred data-sources.

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.

Jump to

Keyboard shortcuts

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