write

package
v2.7.5 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 20 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

View Source
var (
	// ErrLineTooLong is the error returned when reading a line that exceeds MaxLineLength.
	ErrLineTooLong = errors.New("batcher: line too long")
)
View Source
var ErrWriteCanceled = errors.New("write canceled")

Functions

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 BatchWriter

type BatchWriter interface {
	WriteBatches(ctx context.Context, r io.Reader, writeFn func(batch []byte) error) error
}

type BufferBatcher

type BufferBatcher 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
	MaxLineLength    int           // MaxLineLength specifies the maximum length of a single line
}

BufferBatcher batches line protocol for sends to output.

func (*BufferBatcher) WriteBatches

func (b *BufferBatcher) WriteBatches(ctx context.Context, r io.Reader, writeFn func(batch []byte) error) error

WriteBatches reads batches from r, passing them on to an arbitrary writeFn.

type BytesPerSec

type BytesPerSec float64

func ToBytesPerSecond

func ToBytesPerSecond(rateLimit string) (BytesPerSec, error)

ToBytesPerSecond converts rate from string to number. The supplied string value format must be COUNT(B|kB|MB)/TIME(s|sec|m|min) with / and TIME being optional. All spaces are ignored, they can help with formatting. Examples: "5 MB / 5 min", 17kbs. 5.1MB5m.

func (*BytesPerSec) Set

func (b *BytesPerSec) Set(v string) (err error)

func (BytesPerSec) String

func (b BytesPerSec) String() string

type Client

func (Client) Write

func (c Client) Write(ctx context.Context, params *Params) error

type DryRunClient

type DryRunClient struct {
	clients.CLI
	LineReader
}

func (DryRunClient) WriteDryRun

func (c DryRunClient) WriteDryRun(ctx context.Context) error

type HttpClient

type HttpClient interface {
	Do(*http.Request) (*http.Response, error)
}

type InputCompression

type InputCompression int
const (
	InputCompressionDerived InputCompression = iota
	InputCompressionGZIP
	InputCompressionNone
)

func (*InputCompression) Set

func (i *InputCompression) Set(v string) error

func (InputCompression) String

func (i InputCompression) String() string

type InputFormat

type InputFormat int
const (
	InputFormatDerived InputFormat = iota
	InputFormatCSV
	InputFormatLP
)

func (*InputFormat) Set

func (i *InputFormat) Set(v string) error

func (InputFormat) String

func (i InputFormat) String() string

type LineReader

type LineReader interface {
	Open(ctx context.Context) (io.Reader, io.Closer, error)
}

type MultiInputLineReader

type MultiInputLineReader struct {
	StdIn      io.Reader
	HttpClient HttpClient
	ErrorOut   io.Writer

	Args        []string
	Files       []string
	URLs        []string
	Format      InputFormat
	Compression InputCompression
	Encoding    string

	// CSV-specific options.
	Headers                    []string
	SkipRowOnError             bool
	SkipHeader                 int
	IgnoreDataTypeInColumnName bool
	Debug                      bool
}

func (*MultiInputLineReader) Open

type Params

type Params struct {
	clients.OrgBucketParams
	Precision api.WritePrecision
}

type RateLimiter

type RateLimiter interface {
	Throttle(ctx context.Context, in io.Reader) io.Reader
}

type Throttler

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

func NewThrottler

func NewThrottler(bytesPerSec BytesPerSec) *Throttler

func (*Throttler) Throttle

func (t *Throttler) Throttle(ctx context.Context, in io.Reader) io.Reader

Jump to

Keyboard shortcuts

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