client

package
v0.0.0-...-c6d3e3d Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UDPPayloadSize is a reasonable default payload size for UDP packets that
	// could be travelling over the internet.
	UDPPayloadSize = 512
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Query(command string) error

	Write(b []byte) (int, error)
	WriteWithParams(b []byte, params WriteParams) (int, error)

	WriteStream(b io.Reader, contentLength int) (int, error)
	WriteStreamWithParams(b io.Reader, contentLength int, params WriteParams) (int, error)

	Close() error
}

func NewHTTP

func NewHTTP(config HTTPConfig, defaultWP WriteParams) (Client, error)

func NewUDP

func NewUDP(config UDPConfig) (Client, error)

type HTTPConfig

type HTTPConfig struct {
	// URL should be of the form "http://host:port" (REQUIRED)
	URL string

	// UserAgent sets the User-Agent header.
	UserAgent string

	// Timeout specifies a time limit for requests made by this
	// Client. The timeout includes connection time, any
	// redirects, and reading the response body. The timer remains
	// running after Get, Head, Post, or Do return and will
	// interrupt reading of the Response.Body.
	//
	// A Timeout of zero means no timeout.
	Timeout time.Duration

	// Username is the basic auth username for the server.
	Username string
	// Password is the basic auth password for the server.
	Password string

	// TLSConfig is the tls auth settings to use for each request.
	TLSConfig *tls.Config
}

type Response

type Response struct {
	// ignore Results:
	Results []interface{} `json:"-"`
	Err     string        `json:"error,omitempty"`
}

Response represents a list of statement results.

func (*Response) Error

func (r *Response) Error() error

Error returns the first error from any statement. Returns nil if no errors occurred on any statements.

type UDPConfig

type UDPConfig struct {
	// URL should be of the form "udp://host:port"
	// or "udp://[ipv6-host%zone]:port".
	URL string

	// PayloadSize is the maximum size of a UDP client message, optional
	// Tune this based on your network. Defaults to UDPPayloadSize.
	PayloadSize int
}

UDPConfig is the config data needed to create a UDP Client

type WriteParams

type WriteParams struct {
	Database        string
	RetentionPolicy string
	Precision       string
	Consistency     string
}

Jump to

Keyboard shortcuts

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