resources

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressedCsvReader added in v1.5.1

func CompressedCsvReader(path string, readerHandler func(reader *csv.Reader) error, opts ...CsvOption) error

func CompressedCsvWriter added in v1.5.1

func CompressedCsvWriter(path string, writerHandler func(writer *csv.Writer) error, opts ...CsvOption) error

func GetTempFilePath added in v1.5.1

func GetTempFilePath() (string, error)

func NewCsvReader

func NewCsvReader(r io.Reader) *csv.Reader

func NewCsvWriter

func NewCsvWriter(w io.Writer) *csv.Writer

func OpenTempFile added in v1.5.1

func OpenTempFile() (io.WriteCloser, string, error)

func Pipeline

func Pipeline(src chan interface{}, pipes ...Pipe) chan interface{}

func ReadAllLines

func ReadAllLines(
	csvReader *csv.Reader,
	batchSize int,
	onBatch func(batch [][]string, lastReadCount int, totalRead int) error,
	onError func(err error) bool,
) error

func SplitEntityName

func SplitEntityName(fullName, entityType string) (string, int32, error)

Types

type Batcher

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

func NewBatcher

func NewBatcher(batchSize int) *Batcher

func (*Batcher) Map

func (b *Batcher) Map(src chan interface{}) chan interface{}

type CsvOption added in v1.9.0

type CsvOption func(opts *csvOpts)

func WithCloseErrorHandler added in v1.9.0

func WithCloseErrorHandler(handler func(err error)) CsvOption

func WithSeparator added in v1.9.0

func WithSeparator(sep rune) CsvOption

type JsonUnmarshaler

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

func NewJsonUnmarshaler

func NewJsonUnmarshaler(makePtr func() interface{}) *JsonUnmarshaler

func (*JsonUnmarshaler) Goroutines

func (u *JsonUnmarshaler) Goroutines(count int) *JsonUnmarshaler

func (*JsonUnmarshaler) Map

func (u *JsonUnmarshaler) Map(src chan interface{}) chan interface{}

func (*JsonUnmarshaler) OnError

func (u *JsonUnmarshaler) OnError(f func(err error)) *JsonUnmarshaler

func (*JsonUnmarshaler) Unmarshal

func (u *JsonUnmarshaler) Unmarshal(unmarshal func(bytes []byte, ptr interface{}) error) *JsonUnmarshaler

type LineScanner

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

func NewLineScanner

func NewLineScanner(filePattern string, maxBuffSize int) *LineScanner

func (*LineScanner) Lines

func (s *LineScanner) Lines() chan interface{}

func (*LineScanner) OnError

func (s *LineScanner) OnError(f func(err error)) *LineScanner

func (*LineScanner) Reader

func (s *LineScanner) Reader(makeReader func(f *os.File) (io.Reader, error)) *LineScanner

func (*LineScanner) Run

func (s *LineScanner) Run() []Result

iterate from 0 to n, replace index in 'filePattern' and tries to read file it closes channel 'ch' and return if file is not exists

func (*LineScanner) Skip

func (s *LineScanner) Skip(lineCount int) *LineScanner

type Pipe

type Pipe interface {
	Map(src chan interface{}) chan interface{}
}

type Result

type Result struct {
	Errors      map[int]string `json:",omitempty"`
	Lines       int
	ErrorsCount int
	FileName    string
}

Jump to

Keyboard shortcuts

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