bland

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

bland

Bland File Service is the very minimal service for data manipulation. This repository is only the interface, blandimpl is the implementation.

Supports File Formats:

  • Csv Files
  • Json Files
  • Protobuf Files

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CsvFile

type CsvFile interface {
	Header() []string

	Index() map[string]int

	Next() (CsvRecord, error)
}

type CsvFileService

type CsvFileService interface {
	NewCsvStream(fw io.Writer, withGzip bool, valueProcessors ...CsvValueProcessor) CsvWriter

	NewCsvFile(filePath string, valueProcessors ...CsvValueProcessor) (CsvWriter, error)

	OpenCsvStream(fr io.Reader, withGzip bool, valueProcessors ...CsvValueProcessor) (CsvStream, error)

	OpenCsvFile(filePath string, valueProcessors ...CsvValueProcessor) (CsvReader, error)

	CsvFileReader(fd *os.File, valueProcessors ...CsvValueProcessor) (CsvReader, error)

	NewCsvSchema(header []string) CsvSchema

	SplitCsvFile(inputFilePath string, limit int, partFn func(int) string) ([]string, error)

	JoinCsvFiles(outputFilePath string, parts []string) error
}

type CsvReader

type CsvReader interface {
	ReadHeader() (CsvFile, error)

	Read() ([]string, error)

	Close() error
}

type CsvRecord

type CsvRecord interface {
	Record() []string

	Field(name string, def string) string

	Fields() map[string]string
}

type CsvSchema

type CsvSchema interface {
	Record(record []string) CsvRecord
}

type CsvStream

type CsvStream interface {
	Read() ([]string, error)

	Close() error
}

type CsvValueProcessor

type CsvValueProcessor func(string) string

type CsvWriter

type CsvWriter interface {
	Write(values ...string) error

	Close() error
}

type FileService

type FileService interface {
	JsonFileService
	ProtoFileService
	CsvFileService

	BlockSize() int

	SetBlockSize(rwBlockSize int)

	MarshalOptions() protojson.MarshalOptions

	SetMarshalOptions(protojson.MarshalOptions)

	UnmarshalOptions() protojson.UnmarshalOptions

	SetUnmarshalOptions(protojson.UnmarshalOptions)
}

type JsonFileService

type JsonFileService interface {
	NewJsonStream(fd io.Writer, withGzip bool) JsonWriter

	NewJsonFile(filePath string) (JsonWriter, error)

	JsonStream(fr io.Reader, withGzip bool) (JsonReader, error)

	OpenJsonFile(filePath string) (JsonReader, error)

	JsonFile(fd *os.File) (JsonReader, error)

	SplitJsonFile(inputFilePath string, limit int, partFn func(int) string) ([]string, error)

	JoinJsonFiles(outputFilePath string, parts []string) error
}

type JsonReader

type JsonReader interface {
	ReadRaw() (json.RawMessage, error)

	Read(holder interface{}) error

	Close() error
}

type JsonWriter

type JsonWriter interface {
	WriteRaw(message json.RawMessage) error

	Write(object interface{}) error

	Close() error
}

type ProtoFileService

type ProtoFileService interface {
	ProtoStream(r io.Reader, withGzip bool) (ProtoReader, error)

	OpenProtoFile(filePath string) (ProtoReader, error)

	ProtoFile(fd *os.File) (ProtoReader, error)

	NewProtoStream(fd io.Writer, withGzip bool) ProtoWriter

	NewProtoBuf(gzipEnabled bool) (ProtoWriter, error)

	NewProtoFile(filePath string) (ProtoWriter, error)

	SplitProtoFile(inputFilePath string, holder proto.Message, limit int, partFn func(int) string) ([]string, error)

	JoinProtoFiles(outputFilePath string, row proto.Message, parts []string) error
}

type ProtoReader

type ProtoReader interface {
	ReadTo(message proto.Message) error

	Close() error
}

type ProtoWriter

type ProtoWriter interface {
	Write(message proto.Message) ([]byte, error)

	Close() error
}

Jump to

Keyboard shortcuts

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