pipeline

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CSVReader

type CSVReader struct {
	FileName  string
	Separator rune
	// contains filtered or unexported fields
}

CSVReader is implementation of RowReader using CSV as data source.

func (*CSVReader) Close

func (r *CSVReader) Close() error

Close closes CSV file.

func (*CSVReader) HeaderRow

func (r *CSVReader) HeaderRow() []string

HeaderRow returns header row.

func (*CSVReader) Open

func (r *CSVReader) Open() error

Open opens CSV file for reading.

func (*CSVReader) ReadRow

func (r *CSVReader) ReadRow() ([]string, error)

ReadRow reads a single row

func (*CSVReader) RowCount

func (r *CSVReader) RowCount() int64

RowCount returns the number of rows read.

func (*CSVReader) Source

func (r *CSVReader) Source() string

Source returns the source of rows.

type Computer

type Computer interface {
	Compute(map[string]interface{}) (map[string]interface{}, error)
}

Computer is the interface that wraps the functionality of computing field value

type Converter

type Converter interface {
	Convert(map[string]interface{}) (map[string]interface{}, error)
}

Converter is the interface that wraps the functionality of converting field value

type DBConfig

type DBConfig struct {
	User     string
	Password string
	Host     string
	Port     int32
	Db       string
	SSLMode  string `yaml:"sslmode"`
}

DBConfig specifies database connection configurations.

func NewDBConfig

func NewDBConfig(configFile string) (DBConfig, error)

NewDBConfig creates a new database configuration from YAML file.

func (DBConfig) ConnectionString

func (c DBConfig) ConnectionString() string

ConnectionString returns connection string generated from configuration.

type DBSynchronizer

type DBSynchronizer interface {
	// Name returns the table's name
	Name() string

	// DependsOn returns other tables that this table depends on
	DependsOn() []string

	// Create table
	Create(*sql.DB) error

	// Delete all rows from table
	Delete(*sql.DB) error

	// Drop table
	Drop(*sql.DB) error

	// Fill rows
	Fill(*sql.DB) error

	// RowCount returns number of rows that is filled.
	RowCount() int64
}

DBSynchronizer synchronize specs and data with database table.

type FieldProvider

type FieldProvider interface {
	Setup(header []string) error
	ProvideField([]string) (map[string]interface{}, error)
}

FieldProvider is the interface that wraps the functionality of accessing fields.

type RecordReader

type RecordReader struct {
	Name          string
	RowReader     RowReader
	FieldProvider FieldProvider
	Converter     Converter
	Computer      Computer
	Validator     Validator
}

RecordReader is a type that specify record reader.

func (*RecordReader) Close

func (r *RecordReader) Close() error

Close closes the record reader, no further reading allowed.

func (*RecordReader) Open

func (r *RecordReader) Open() error

Open opens the record reader for reading.

func (*RecordReader) ReadRecord

func (r *RecordReader) ReadRecord() (map[string]interface{}, error)

ReadRecord reads a single record.

type RowReader

type RowReader interface {
	Open() error
	ReadRow() ([]string, error)
	HeaderRow() []string
	Close() error

	// RowCount returns the number of rows read.
	RowCount() int64

	// Source returns the source of rows.
	Source() string
}

RowReader is the interface that wraps the functionality of row reader.

type Validator

type Validator interface {
	Validate(map[string]interface{}) error
}

Validator is the interface that wraps the functionality of validating field value

Jump to

Keyboard shortcuts

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