proto

package
v0.0.0-...-8d51551 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2016 License: BSD-2-Clause Imports: 5 Imported by: 1

Documentation

Overview

Package proto provides helper functions for using the SysDB front-end protocol. That's the protocol used for communication between a client and a SysDB server instance.

Index

Constants

View Source
const (
	// ConnectionOK indicates that a command was successful.
	ConnectionOK = Status(0)
	// ConnectionError indicates that a command has failed.
	ConnectionError = Status(1)
	// ConnectionLog indicates an (asynchronous) log message.
	ConnectionLog = Status(2)

	// ConnectionData indicates a successful query returning data.
	ConnectionData = Status(100)
)
View Source
const (
	// ConnectionIdle is the internal state for idle connections.
	ConnectionIdle = Status(0)
	// ConnectionPing is the state requesting a connection check.
	ConnectionPing = Status(1)
	// ConnectionStartup is the state requesting the setup of a client
	// connection.
	ConnectionStartup = Status(2)

	// ConnectionQuery is the state requesting the execution of a query in the
	// server.
	ConnectionQuery = Status(3)
	// ConnectionFetch is the state requesting the execution of the 'FETCH'
	// command in the server.
	ConnectionFetch = Status(4)
	// ConnectionList is the state requesting the execution of the 'LIST'
	// command in the server.
	ConnectionList = Status(5)
	// ConnectionLookup is the state requesting the execution of the 'LOOKUP'
	// command in the server.
	ConnectionLookup = Status(6)
	// ConnectionTimeseries is the state requesting the execution of the
	// 'TIMESERIES' command in the server.
	ConnectionTimeseries = Status(7)

	// ConnectionStore is the state requesting the execution of the 'STORE'
	// command in the server.
	ConnectionStore = Status(50)

	// Object-specific STORE commands.
	ConnectionStoreHost      = Status(51)
	ConnectionStoreService   = Status(52)
	ConnectionStoreMetric    = Status(53)
	ConnectionStoreAttribute = Status(54)

	// ConnectionMatcher is the internal state for parsing matchers.
	ConnectionMatcher = Status(100)
	// ConnectionExpr is the internal state for parsing expressions.
	ConnectionExpr = Status(101)

	// ConnectionServerVersion is the state requesting the server version.
	ConnectionServerVersion = Status(1000)
)

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(s string) string

EscapeString returns the quoted and escaped string s suitable for use in a query.

func Unmarshal

func Unmarshal(m *Message, v interface{}) error

Unmarshal parses the raw body of m and stores the result in the value pointed to by v which has to match the type of the message and its data.

func Write

func Write(w io.Writer, m *Message) error

Write writes a raw message to w. The raw body of m has to be encoded in the SysDB wire format. The function adds the right header to the message.

The writer has to be in blocking mode. Otherwise, the client and server will be out of sync after writing a partial message and cannot recover from that.

Types

type DataType

type DataType int

The DataType describes the type of data in a ConnectionData message.

const (
	// A HostList can be unmarshaled to []sysdb.Host.
	HostList DataType = iota
	// A Host can be unmarshaled to sysdb.Host.
	Host
	// A Timeseries can be unmarshaled to sysdb.Timeseries.
	Timeseries
)

type Message

type Message struct {
	Type Status
	Raw  []byte
}

A Message represents a raw message of the SysDB front-end protocol.

func Read

func Read(r io.Reader) (*Message, error)

Read reads a raw message encoded in the SysDB wire format from r. The function parses the header but the raw body of the message will still be encoded in the wire format.

The reader has to be in blocking mode. Otherwise, the client and server will be out of sync after reading a partial message and cannot recover from that.

func (Message) DataType

func (m Message) DataType() (DataType, error)

DataType determines the type of data in a ConnectionData message.

type Status

type Status uint32

A Status represents the type of a message. The message type describes the current status or state of a connection depending on the context.

Jump to

Keyboard shortcuts

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