config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 3 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 sets the output format for CLI and Web interfaces.
	// There are 3 formats available: 'CSV', 'CompactJSON' and
	// 'PrettyJSON'.
	Format format.Format

	// JobsNum sets a level of parallelism used during parsing of
	// a stream of name-strings.
	JobsNum int

	// BatchSize sets the maximum number of elements in names-strings slice.
	BatchSize int

	// WithStream changes from parsing a batch by batch, to parsing one name
	// at a time. When WithStream is true, BatchSize setting is ignored.
	WithStream bool

	// IgnoreHTMLTags can be set to true when it is desirable to clean up names from
	// a few HTML tags often present in names-strings that were planned to be
	// presented via an HTML page.
	IgnoreHTMLTags bool

	// WithDetails can be set to true when a simplified output is not sufficient
	// for obtaining a required information.
	WithDetails bool

	// Port to run wer-service.
	Port int

	// IsTest can be set to true when parsing functionality is used for tests.
	// In such cases the `ParserVersion` field is presented as `test_version`
	// instead of displaying the actual version of `gnparser`.
	IsTest bool
}

Config keeps settings that might affect how parsing is done, of change the parsing output.

func NewConfig

func NewConfig(opts ...Option) Config

NewConfig generates a new Config object. It can take an arbitrary number of `Opt` functions to modify default configuration settings.

type Option

type Option func(*Config)

Option is a type that has to be returned by all Option functions. Such functions are able to modify the settings of a Config object.

func OptBatchSize

func OptBatchSize(i int) Option

OptBatchSize sets the max number of names in a batch.

func OptFormat

func OptFormat(s string) Option

OptFormat takes a string (one of 'csv', 'compact', 'pretty') to set the formatting option for the CLI or Web presentation. If some other string is entered, the default, 'CSV' format is set, accompanied by a warning.

func OptIgnoreHTMLTags

func OptIgnoreHTMLTags(b bool) Option

OptKeepHTMLTags sets the RemoveHTML field.

func OptIsTest

func OptIsTest(b bool) Option

OptIsTest sets a test flag.

func OptJobsNum

func OptJobsNum(i int) Option

OptJobsNum sets the JobsNum field.

func OptPort

func OptPort(i int) Option

OptPort sets a port for web-service.

func OptWithDetails

func OptWithDetails(b bool) Option

OptWithDetails sets the WithDetails field.

func OptWithStream

func OptWithStream(b bool) Option

OptWithDetails sets the WithDetails field.

Jump to

Keyboard shortcuts

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