write

package
v2.0.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxBytes is 500KB; this is typically 250 to 500 lines.
	DefaultMaxBytes = 500000
	// DefaultInterval will flush every 10 seconds.
	DefaultInterval = 10 * time.Second
)

Variables

This section is empty.

Functions

func CsvToProtocolLines

func CsvToProtocolLines(reader io.Reader) io.Reader

CsvToProtocolLines transforms csv data into line protocol data

func IsTypeSupported

func IsTypeSupported(dataType string) bool

IsTypeSupported returns true if the data type is supported

func ScanLines

func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error)

ScanLines is used in bufio.Scanner.Split to split lines of line protocol.

Types

type Batcher

type Batcher struct {
	MaxFlushBytes    int                   // MaxFlushBytes is the maximum number of bytes to buffer before flushing
	MaxFlushInterval time.Duration         // MaxFlushInterval is the maximum amount of time to wait before flushing
	Service          platform.WriteService // Service receives batches flushed from Batcher.
}

Batcher batches line protocol for sends to output.

func (*Batcher) Write

func (b *Batcher) Write(ctx context.Context, org, bucket platform.ID, r io.Reader) error

Write reads r in batches and sends to the output.

type CsvColumnError

type CsvColumnError struct {
	Column string
	Err    error
}

CsvColumnError indicates conversion in a specific column

func (CsvColumnError) Error

func (e CsvColumnError) Error() string

type CsvLineError

type CsvLineError struct {
	Line int
	Err  error
}

CsvLineError is returned for csv conversion errors Line numbers are 1-indexed

func (CsvLineError) Error

func (e CsvLineError) Error() string

type CsvTable

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

CsvTable gathers metadata about columns

func (*CsvTable) AddRow

func (t *CsvTable) AddRow(row []string) bool

AddRow adds header, comment or data row

func (*CsvTable) AppendLine

func (t *CsvTable) AppendLine(buffer []byte, row []string) ([]byte, error)

AppendLine appends a protocol line to the supplied buffer and returns appended buffer or an error if any

func (*CsvTable) Column

func (t *CsvTable) Column(label string) *CsvTableColumn

Column returns the first column of the supplied label or nil

func (*CsvTable) Columns

func (t *CsvTable) Columns() []CsvTableColumn

Columns returns available columns

func (*CsvTable) CreateLine

func (t *CsvTable) CreateLine(row []string) (line string, err error)

CreateLine produces a protocol line out of the supplied row or returns error

func (*CsvTable) FieldName

func (t *CsvTable) FieldName() *CsvTableColumn

FieldName returns field name column or nil

func (*CsvTable) FieldValue

func (t *CsvTable) FieldValue() *CsvTableColumn

FieldValue returns field value column or nil

func (*CsvTable) Fields

func (t *CsvTable) Fields() []CsvTableColumn

Fields returns fields

func (*CsvTable) Measurement

func (t *CsvTable) Measurement() *CsvTableColumn

Measurement returns measurement column or nil

func (*CsvTable) Tags

func (t *CsvTable) Tags() []CsvTableColumn

Tags returns tags

func (*CsvTable) Time

func (t *CsvTable) Time() *CsvTableColumn

Time returns time column or nil

type CsvTableColumn

type CsvTableColumn struct {
	// label such as "_start", "_stop", "_time"
	Label string
	// "string", "long", "dateTime:RFC3339" ...
	DataType string
	// column's line part (0 means not determined), see linePart constants
	LinePart int
	// default value to be used for rows where value is an empty string.
	DefaultValue string
	// index of this column in the table row
	Index int
	// contains filtered or unexported fields
}

CsvTableColumn represents metadata of a csv column

func (*CsvTableColumn) LineLabel

func (c *CsvTableColumn) LineLabel() string

LineLabel returns escaped column name so that it can be used as tag name or field name in line protocol

Jump to

Keyboard shortcuts

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