input

package
v0.0.0-...-95e2e8c Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XmlInputPropertyTypePrimitive = XmlInputPropertyType("primitive")
	XmlInputPropertyTypeArray     = XmlInputPropertyType("array")
	XmlInputPropertyTypeObject    = XmlInputPropertyType("object")
)

Variables

This section is empty.

Functions

func Close

func Close(inputs List) error

Types

type Config

type Config interface {
	Validate(parsers map[string]parser.Config, log *logrus.Entry) error
	GetName() string
	ShouldDieOnInputChange() bool
}

type Csv

type Csv struct {
	// contains filtered or unexported fields
}

func NewCsv

func NewCsv(
	config *CsvConfig,
	parsers parser.List,
) (*Csv, error)

func (*Csv) Close

func (csvInput *Csv) Close() error

func (*Csv) Get

func (csvInput *Csv) Get(position record.Position) (record.Record, error)

func (*Csv) IterateAll

func (csvInput *Csv) IterateAll() (record.Iterator, func() error, error)

func (*Csv) ModTime

func (csvInput *Csv) ModTime() (time.Time, error)

func (*Csv) Name

func (csvInput *Csv) Name() string

func (*Csv) Size

func (csvInput *Csv) Size() (int64, error)

type CsvColumnConfig

type CsvColumnConfig struct {
	Name   string `yaml:"name"`
	Parser string `yaml:"parser"`
}

func (*CsvColumnConfig) Validate

func (config *CsvColumnConfig) Validate(parsers map[string]parser.Config, log *logrus.Entry, logPrefix string) error

type CsvConfig

type CsvConfig struct {
	Name              string             `yaml:"name"`
	Type              string             `yaml:"type"`
	Path              string             `yaml:"path"`
	DieOnInputChange  *bool              `yaml:"dieOnInputChange"`
	IgnoreFirstRow    bool               `yaml:"ignoreFirstRow"`
	AutodetectColumns bool               `yaml:"autodetectColumns"`
	Delimiter         string             `yaml:"delimiter"`
	Columns           []*CsvColumnConfig `yaml:"columns"`
	ColumnIndexByName map[string]int
	Logger            *logrus.Entry
}

func (*CsvConfig) GetName

func (config *CsvConfig) GetName() string

func (*CsvConfig) ShouldDieOnInputChange

func (config *CsvConfig) ShouldDieOnInputChange() bool

func (*CsvConfig) Validate

func (config *CsvConfig) Validate(parsers map[string]parser.Config, log *logrus.Entry) error

type CsvRecord

type CsvRecord struct {
	// contains filtered or unexported fields
}

func NewCsvRecord

func NewCsvRecord(
	config *CsvConfig,
	columnParsers []parser.Parser,
	data []string,
	position recordPackage.Position,
) *CsvRecord

func (*CsvRecord) All

func (record *CsvRecord) All() (map[string]interface{}, error)

func (*CsvRecord) Get

func (record *CsvRecord) Get(path string) (interface{}, error)

func (*CsvRecord) Position

func (record *CsvRecord) Position() recordPackage.Position

type Input

type Input interface {
	Name() string
	Get(position record.Position) (record.Record, error)
	Size() (int64, error)
	ModTime() (time.Time, error)

	// Iterates all the records in the input, ordered
	// from the smallest to the biggest position
	// The second returned parameter is a callback that
	// must be used to close the relevant resources
	IterateAll() (record.Iterator, func() error, error)

	Close() error
}

func NewFromConfig

func NewFromConfig(
	config Config,
	parsers parser.List,
) (Input, error)

type Json

type Json struct {
	// contains filtered or unexported fields
}

func NewJson

func NewJson(config *JsonConfig) (*Json, error)

func (*Json) Close

func (jsonInput *Json) Close() error

func (*Json) Get

func (jsonInput *Json) Get(position record.Position) (record.Record, error)

func (*Json) IterateAll

func (jsonInput *Json) IterateAll() (record.Iterator, func() error, error)

func (*Json) ModTime

func (jsonInput *Json) ModTime() (time.Time, error)

func (*Json) Name

func (jsonInput *Json) Name() string

func (*Json) Size

func (jsonInput *Json) Size() (int64, error)

type JsonConfig

type JsonConfig struct {
	Name             string `yaml:"name"`
	Type             string `yaml:"type"`
	Path             string `yaml:"path"`
	DieOnInputChange *bool  `yaml:"dieOnInputChange"`
	Logger           *logrus.Entry
}

func (*JsonConfig) GetName

func (config *JsonConfig) GetName() string

func (*JsonConfig) ShouldDieOnInputChange

func (config *JsonConfig) ShouldDieOnInputChange() bool

func (*JsonConfig) Validate

func (config *JsonConfig) Validate(parsers map[string]parser.Config, log *logrus.Entry) error

type JsonRecord

type JsonRecord struct {
	// contains filtered or unexported fields
}

func NewJsonRecord

func NewJsonRecord(
	config *JsonConfig,
	data map[string]interface{},
	position record.Position,
) *JsonRecord

func (*JsonRecord) All

func (record *JsonRecord) All() (map[string]interface{}, error)

func (*JsonRecord) Get

func (record *JsonRecord) Get(path string) (interface{}, error)

func (*JsonRecord) Position

func (record *JsonRecord) Position() record.Position

type List

type List = map[string]Input

func NewFromConfigs

func NewFromConfigs(
	configs map[string]Config,
	parsers parser.List,
) (List, error)

type Mock

type Mock struct {
	// contains filtered or unexported fields
}

func NewMock

func NewMock(parser parser.Parser, data []record.Record) *Mock

func (*Mock) Close

func (mock *Mock) Close() error

func (*Mock) Get

func (mock *Mock) Get(position record.Position) (record.Record, error)

func (*Mock) IterateAll

func (mock *Mock) IterateAll() (record.Iterator, func() error, error)

func (*Mock) ModTime

func (mock *Mock) ModTime() (time.Time, error)

func (*Mock) Name

func (mock *Mock) Name() string

func (*Mock) SetModTime

func (mock *Mock) SetModTime(time time.Time)

func (*Mock) Size

func (mock *Mock) Size() (int64, error)

type Xml

type Xml struct {
	// contains filtered or unexported fields
}

func NewXml

func NewXml(
	config *XmlConfig,
	parsers parser.List,
) (*Xml, error)

func (*Xml) Close

func (xmlInput *Xml) Close() error

func (*Xml) Get

func (xmlInput *Xml) Get(position record.Position) (record.Record, error)

func (*Xml) IterateAll

func (xmlInput *Xml) IterateAll() (record.Iterator, func() error, error)

func (*Xml) ModTime

func (xmlInput *Xml) ModTime() (time.Time, error)

func (*Xml) Name

func (xmlInput *Xml) Name() string

func (*Xml) Size

func (xmlInput *Xml) Size() (int64, error)

type XmlConfig

type XmlConfig struct {
	Name             string               `yaml:"name"`
	Type             string               `yaml:"type"`
	Path             string               `yaml:"path"`
	DieOnInputChange *bool                `yaml:"dieOnInputChange"`
	Properties       []*XmlPropertyConfig `yaml:"properties"`
	RecordXPath      string               `yaml:"recordXpath"`
	Logger           *logrus.Entry
}

func (*XmlConfig) GetName

func (config *XmlConfig) GetName() string

func (*XmlConfig) ShouldDieOnInputChange

func (config *XmlConfig) ShouldDieOnInputChange() bool

func (*XmlConfig) Validate

func (config *XmlConfig) Validate(parsers map[string]parser.Config, log *logrus.Entry) error

type XmlInputPropertyType

type XmlInputPropertyType string

type XmlPropertyConfig

type XmlPropertyConfig struct {
	Name          string               `yaml:"name"`
	Type          XmlInputPropertyType `yaml:"type"`
	Parser        string               `yaml:"parser"`
	XPath         string               `yaml:"xpath"`
	Items         *XmlPropertyConfig   `yaml:"items"`
	Properties    []*XmlPropertyConfig `yaml:"properties"`
	CompiledXPath *xpath.Expr
}

func (*XmlPropertyConfig) Validate

func (config *XmlPropertyConfig) Validate(
	parsers map[string]parser.Config,
	nameRequired bool,
	log *logrus.Entry,
	logPrefix string,
) error

type XmlRecord

type XmlRecord struct {
	// contains filtered or unexported fields
}

func NewXmlRecord

func NewXmlRecord(
	config *XmlConfig,
	node *xmlquery.Node,
	parsers parserPackage.List,
	position recordPackage.Position,
) (*XmlRecord, error)

func (*XmlRecord) All

func (record *XmlRecord) All() (map[string]interface{}, error)

func (*XmlRecord) Get

func (record *XmlRecord) Get(path string) (interface{}, error)

func (*XmlRecord) Position

func (record *XmlRecord) Position() recordPackage.Position

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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