feeder

package
v0.0.0-...-1b8d80d Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrUnsupportedEncoding signals an encoding that cannot be converted
	ErrUnsupportedEncoding = errors.New("Unsupported encoding")
	//ErrAuthorization declares a permission issue
	ErrAuthorization = errors.New("Permission denied")
	//ErrTimeout indicates a timeout
	ErrTimeout = errors.New("Timeout")
	//ErrNotFound states there is no convention file
	ErrNotFound = errors.New("No convention file")
)
View Source
var (
	//Integer is a regex to express the integer part for a possible real number.
	//We just ignore the floating part
	Integer = regexp.MustCompile(`^(\d+)`)
)

Functions

This section is empty.

Types

type ConventionReader

type ConventionReader interface {
	Reader(year int, promotion string) (io.Reader, error)
}

ConventionReader interfaces the source where to read conventions

type Conventions

type Conventions interface {
	Import() ([]schema.Convention, *ImportError)
}

Conventions allows to import conventions

type CsvConventions

type CsvConventions struct {
	Reader ConventionReader
	Year   int
	// contains filtered or unexported fields
}

CsvConventions parses conventions from CSV files

func NewCsvConventions

func NewCsvConventions(r ConventionReader, promotions []string) *CsvConventions

NewCsvConventions creates an importer from a given reader By default, the parsed year is the current year

func (*CsvConventions) Import

func (f *CsvConventions) Import() ([]schema.Convention, *ImportError)

Import imports all the conventions by requesting in parallel the conventions for each registered promotions

type HTTPConventionReader

type HTTPConventionReader struct {
	Encoding string
	// contains filtered or unexported fields
}

HTTPConventionReader reads conventions that are made available from the Http server

func NewHTTPConventionReader

func NewHTTPConventionReader(url, login, password string) *HTTPConventionReader

NewHTTPConventionReader creates a new reader. Default encoding is "windows-1252"

func (*HTTPConventionReader) Reader

func (h *HTTPConventionReader) Reader(year int, promotion string) (io.Reader, error)

Reader read all the conventions for a given year and promotion

type ImportError

type ImportError struct {
	Warnings []string
	Fatal    error
}

ImportError to report a critical error and multiple warnings

func NewImportError

func NewImportError() *ImportError

NewImportError creates a new error

func (*ImportError) Error

func (e *ImportError) Error() string

Error reports the critical errors and the possible warnings.

func (*ImportError) NewWarning

func (e *ImportError) NewWarning(err ...string)

NewWarning signal a new warning to report

Jump to

Keyboard shortcuts

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