voltdbclient

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PingHandle      = math.MaxInt64
	AsyncTopoHandle = PingHandle - 1
)

Handles

View Source
const (
	PartitionIDBits = 14

	// maximum values for the txn id fields
	PartitionIDMaxValue = (1 << PartitionIDBits) - 1
	MPInitPID           = PartitionIDMaxValue
)

Partitions

View Source
const (
	BinArrayFormat = 0
	JSONFormat     = 1
)

Hash Config Format

View Source
const (
	// BlockDuration ...
	BlockDuration = time.Millisecond * 100
	// OutTXNsLimit defines the amount of outstanding transactions we'd allow.
	OutTXNsLimit = 20 // as many outstanding transactions as we ever want.
)
View Source
const (
	// DefaultQueryTimeout time out for queries.
	DefaultQueryTimeout time.Duration = 2 * time.Minute
)
View Source
const (
	Elastic = "Elastic"
)

Hash Type

Variables

View Source
var ErrMissingServerArgument = errors.New("voltdbclient: missing voltdb connection string")
View Source
var ProtocolVersion = 1

ProtocolVersion lists the version of the voltdb wire protocol to use. For VoltDB releases of version 5.2 and later use version 1. For releases prior to that use version 0.

Functions

func EncodePI

func EncodePI(e *wire.Encoder, pi *procedureInvocation) error

func SearchToken2Partitions

func SearchToken2Partitions(a []token2Partition, token int) (partition int)

SearchToken2Partitions searches the needed partition by token.

Types

type AsyncResponseConsumer

type AsyncResponseConsumer interface {

	// This method is invoked when an error is returned by an async Query
	// or an Exec.
	ConsumeError(error)
	// This method is invoked when a Result is returned by an async Exec.
	ConsumeResult(driver.Result)
	// This method is invoked when Rows is returned by an async Query.
	ConsumeRows(driver.Rows)
}

AsyncResponseConsumer is a type that consumes responses from asynchronous Queries and Execs. In the VoltDB go client, asynchronous requests are continuously processed by one or more goroutines executing in the background. When a response from the server is received for an asynchronous request, one of the methods in this interface is invoked. An instance of AyncResponseConsumer is passed when an asynchronous request is made, this instance will process the response for that request.

type Conn

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

Conn holds the set of currently active connections.

func OpenConn

func OpenConn(ci string) (*Conn, error)

OpenConn returns a new connection to the VoltDB server. The name is a string in a driver-specific format. The returned connection can be used by only one goroutine at a time.

By default voltdb doesn't require authentication, clients connecting to un secured database have access to everything. Supplying connection credentials doesn't affect for non secured databases

Here we authenticate if username and password are supplied, if they are not then a connection is established without doing the authentication

Connection string is similar to postgres, default port is 21212

voltdb:// voltdb://localhost voltdb://localhost:21212 voltdb://user@localhost voltdb://user:secret@localhost voltdb://other@localhost?some_param=some_value

You can omit the port,and the default port of 21212 will be automatically added for you.

Additionally you can fine tune behavior of connections when in cluster mode using query parameters.

Example localhost:21212?max_retries=10&retry=true&retry_interval=1s

retry - if true will try to reconnect with the node when the connection is lost.

max_retries - in the number of times you want to retry to connect to a node. This has no effect when retry is false.

retry_interval is the duration of time to wait until the next retry.

func OpenConnWithLatencyTarget

func OpenConnWithLatencyTarget(ci string, latencyTarget int32) (*Conn, error)

OpenConnWithLatencyTarget returns a new connection to the VoltDB server. This connection will try to meet the specified latency target, potentially by throttling the rate at which asynchronous transactions are submitted.

func OpenConnWithMaxOutstandingTxns

func OpenConnWithMaxOutstandingTxns(ci string, maxOutTxns int) (*Conn, error)

OpenConnWithMaxOutstandingTxns returns a new connection to the VoltDB server. This connection will limit the number of outstanding transactions as indicated. An outstanding transaction is a transaction that has been sent to the server but for which no response has been received.

func (*Conn) Begin

func (c *Conn) Begin() (driver.Tx, error)

Begin starts a transaction.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection to the VoltDB server. Connections to the server are meant to be long lived; it should not be necessary to continually close and reopen connections. Close would typically be called using a defer. Operations using a closed connection cause a panic.

func (*Conn) Drain

func (c *Conn) Drain()

Drain blocks until all outstanding asynchronous requests have been satisfied. Asynchronous requests are processed in a background thread; this call blocks the current thread until that background thread has finished with all asynchronous requests.

func (*Conn) DumpConn added in v1.0.1

func (c *Conn) DumpConn()

func (*Conn) Exec

func (c *Conn) Exec(query string, args []driver.Value) (driver.Result, error)

Exec executes a query that doesn't return rows, such as an INSERT or UPDATE. Exec is available on both VoltConn and on VoltStatement. Uses DefaultQueryTimeout.

func (*Conn) ExecAsync

func (c *Conn) ExecAsync(resCons AsyncResponseConsumer, query string, args []driver.Value)

ExecAsync is analogous to Exec but is run asynchronously. That is, an invocation of this method blocks only until a request is sent to the VoltDB server. Uses DefaultQueryTimeout.

func (*Conn) ExecAsyncTimeout

func (c *Conn) ExecAsyncTimeout(resCons AsyncResponseConsumer, query string, args []driver.Value, timeout time.Duration) error

ExecAsyncTimeout is analogous to Exec but is run asynchronously. That is, an invocation of this method blocks only until a request is sent to the VoltDB server. Specifies a duration for timeout.

func (*Conn) ExecTimeout

func (c *Conn) ExecTimeout(query string, args []driver.Value, timeout time.Duration) (driver.Result, error)

ExecTimeout executes a query that doesn't return rows, such as an INSERT or UPDATE. ExecTimeout is available on both VoltConn and on VoltStatement. Specifies a duration for timeout.

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (driver.Stmt, error)

Prepare creates a prepared statement for later queries or executions. The Statement returned by Prepare is bound to this VoltConn.

func (*Conn) Query

func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)

Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query. Uses DefaultQueryTimeout.

func (*Conn) QueryAsync

func (c *Conn) QueryAsync(rowsCons AsyncResponseConsumer, query string, args []driver.Value)

QueryAsync executes a query asynchronously. The invoking thread will block until the query is sent over the network to the server. The eventual response will be handled by the given AsyncResponseConsumer, this processing happens in the 'response' thread. Uses DefaultQueryTimeout.

func (*Conn) QueryAsyncTimeout

func (c *Conn) QueryAsyncTimeout(rowsCons AsyncResponseConsumer, query string, args []driver.Value, timeout time.Duration) error

QueryAsyncTimeout executes a query asynchronously. The invoking thread will block until the query is sent over the network to the server. The eventual response will be handled by the given AsyncResponseConsumer, this processing happens in the 'response' thread. Specifies a duration for timeout.

func (*Conn) QueryTimeout

func (c *Conn) QueryTimeout(query string, args []driver.Value, timeout time.Duration) (driver.Rows, error)

QueryTimeout executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query. Specifies a duration for timeout.

type ResponseStatus

type ResponseStatus int8

ResponseStatus handles the Status codes returned by the VoltDB server. Each response to a client Query or Exec has an associated status code.

const (
	Success                    ResponseStatus = 1
	UserAbort                  ResponseStatus = -1
	GracefulFailure            ResponseStatus = -2
	UnexpectedFailure          ResponseStatus = -3
	ConnectionLost             ResponseStatus = -4
	ServerUnavailable          ResponseStatus = -5
	ConnectionTimeout          ResponseStatus = -6
	ResponseUnknown            ResponseStatus = -7
	TXNRestart                 ResponseStatus = -8
	OperationalFailure         ResponseStatus = -9
	UninitializedAppStatusCode ResponseStatus = -128
)

The available ResponseStatus codes

func (ResponseStatus) String

func (rs ResponseStatus) String() string

Represent a ResponseStatus as a string.

type Token2PartitionSlice

type Token2PartitionSlice []token2Partition

Token2PartitionSlice holds a slice of token2Partition structures.

func (Token2PartitionSlice) Len

func (s Token2PartitionSlice) Len() int

func (Token2PartitionSlice) Less

func (s Token2PartitionSlice) Less(i, j int) bool

func (Token2PartitionSlice) Sort

func (s Token2PartitionSlice) Sort()

Sort is a convenience method.

func (Token2PartitionSlice) Swap

func (s Token2PartitionSlice) Swap(i, j int)

type VoltDriver

type VoltDriver struct{}

VoltDriver implements A database/sql/driver for VoltDB. This driver is registered as 'voltdb'

func NewVoltDriver

func NewVoltDriver() *VoltDriver

NewVoltDriver returns a new instance of a VoltDB driver.

func (*VoltDriver) Open

func (vd *VoltDriver) Open(hostAndPort string) (driver.Conn, error)

Open a connection to the VoltDB server.

type VoltError

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

VoltError type

type VoltResult

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

VoltResult is an implementation of database/sql/driver.Result

func (*VoltResult) AdvanceTable

func (vr *VoltResult) AdvanceTable() bool

AdvanceTable advances to the next table. Returns false if there isn't a next table.

func (*VoltResult) AdvanceToTable

func (vr *VoltResult) AdvanceToTable(ti int) bool

AdvanceToTable advances to the table indicated by the index. Returns false if there is no table at the given index.

func (VoltResult) LastInsertId

func (vr VoltResult) LastInsertId() (int64, error)

LastInsertId is not populated by VoltDB, calls to LastInsertId return 0.

func (VoltResult) RowsAffected

func (vr VoltResult) RowsAffected() (int64, error)

RowsAffected returns the number of rows affected by the query.

type VoltRows

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

VoltRows is an implementation of database/sql/driver.Rows.

A response to a query from the VoltDB server might include rows from more than one table; VoltRows includes methods used to move between tables.

VoltRows also includes two column accessors for each VoltDB column type. The value for a column can be accessed by either column index or by column name. These accessors return interface{} type; the returned interface needs to be cast to the correct type. This is how null database values are supported, a null value will be returned as nil.

func (VoltRows) AdvanceRow

func (vr VoltRows) AdvanceRow() bool

AdvanceRow advances to the next row of data, returns false if there isn't a next row.

func (*VoltRows) AdvanceTable

func (vr *VoltRows) AdvanceTable() bool

AdvanceTable advances to the next table. Returns false if there isn't a next table.

func (VoltRows) AdvanceToRow

func (vr VoltRows) AdvanceToRow(rowIndex int32) bool

AdvanceToRow advances to the row of data indicated by the index. Returns false if there is no row at the given index.

func (*VoltRows) AdvanceToTable

func (vr *VoltRows) AdvanceToTable(tableIndex int16) bool

AdvanceToTable advances to the table indicated by the index. Returns false if there is no table at the given index.

func (VoltRows) Close

func (vr VoltRows) Close() error

Close is essentially a no op as the VoltDB server doesn't support cursors.

func (VoltRows) ColumnCount

func (vr VoltRows) ColumnCount() int

ColumnCount returns the number of columns in the current table.

func (VoltRows) ColumnTypes

func (vr VoltRows) ColumnTypes() []int8

ColumnTypes returns the column types of the columns in the current table.

func (VoltRows) Columns

func (vr VoltRows) Columns() []string

Columns returns the names of the columns.

func (VoltRows) GetBigInt

func (vr VoltRows) GetBigInt(colIndex int16) (interface{}, error)

GetBigInt returns the value of a BIGINT column at the given index in the current row.

func (VoltRows) GetBigIntByName

func (vr VoltRows) GetBigIntByName(cn string) (interface{}, error)

GetBigIntByName returns the value of a BIGINT column with the given name in the current row.

func (VoltRows) GetDecimal

func (vr VoltRows) GetDecimal(colIndex int16) (interface{}, error)

GetDecimal returns the value of a DECIMAL column at the given index in the current row.

func (VoltRows) GetDecimalByName

func (vr VoltRows) GetDecimalByName(cn string) (interface{}, error)

GetDecimalByName returns the value of a DECIMAL column with the given name in the current row.

func (VoltRows) GetFloat

func (vr VoltRows) GetFloat(colIndex int16) (interface{}, error)

GetFloat returns the value of a FLOAT column at the given index in the current row.

func (VoltRows) GetFloatByName

func (vr VoltRows) GetFloatByName(cn string) (interface{}, error)

GetFloatByName returns the value of a FLOAT column with the given name in the current row.

func (VoltRows) GetInteger

func (vr VoltRows) GetInteger(colIndex int16) (interface{}, error)

GetInteger returns the value of a INTEGER column at the given index in the current row.

func (VoltRows) GetIntegerByName

func (vr VoltRows) GetIntegerByName(cn string) (interface{}, error)

GetIntegerByName returns the value of a INTEGER column with the given name in the current row.

func (VoltRows) GetSmallInt

func (vr VoltRows) GetSmallInt(colIndex int16) (interface{}, error)

GetSmallInt returns the value of a SMALLINT column at the given index in the current row.

func (VoltRows) GetSmallIntByName

func (vr VoltRows) GetSmallIntByName(cn string) (interface{}, error)

GetSmallIntByName returns the value of a SMALLINT column with the given name in the current row.

func (VoltRows) GetString

func (vr VoltRows) GetString(colIndex int16) (interface{}, error)

GetString returns the value of a STRING column at the given index in the current row.

func (VoltRows) GetStringByName

func (vr VoltRows) GetStringByName(cn string) (interface{}, error)

GetStringByName returns the value of a STRING column with the given name in the current row.

func (VoltRows) GetTimestamp

func (vr VoltRows) GetTimestamp(colIndex int16) (interface{}, error)

GetTimestamp returns the value of a TIMESTAMP column at the given index in the current row.

func (VoltRows) GetTimestampByName

func (vr VoltRows) GetTimestampByName(cn string) (interface{}, error)

GetTimestampByName returns the value of a TIMESTAMP column with the given name in the current row.

func (VoltRows) GetTinyInt

func (vr VoltRows) GetTinyInt(colIndex int16) (interface{}, error)

GetTinyInt returns the value of a TINYINT column at the given index in the current row.

func (VoltRows) GetTinyIntByName

func (vr VoltRows) GetTinyIntByName(cn string) (interface{}, error)

GetTinyIntByName returns the value of a TINYINT column with the given name in the current row.

func (VoltRows) GetVarbinary

func (vr VoltRows) GetVarbinary(colIndex int16) (interface{}, error)

GetVarbinary returns the value of a VARBINARY column at the given index in the current row.

func (VoltRows) GetVarbinaryByName

func (vr VoltRows) GetVarbinaryByName(cn string) (interface{}, error)

GetVarbinaryByName returns the value of a VARBINARY column with the given name in the current row.

func (VoltRows) Next

func (vr VoltRows) Next(dest []driver.Value) (err error)

Next is called to populate the next row of data into the provided slice. The provided slice will be the same size as the Columns() are wide.

type VoltStatement

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

VoltStatement is an implementation of the database/sql/driver.Stmt interface

func (VoltStatement) Close

func (vs VoltStatement) Close() error

Close closes the statement. Close is a noop for VoltDB as the VoltDB server does not directly support prepared statements.

func (VoltStatement) Exec

func (vs VoltStatement) Exec(args []driver.Value) (driver.Result, error)

Exec executes a query that doesn't return rows, such as an INSERT or UPDATE. Uses DefaultQueryTimeout.

func (VoltStatement) ExecAsync

func (vs VoltStatement) ExecAsync(resCons AsyncResponseConsumer, args []driver.Value)

ExecAsync asynchronously runs an Exec. Uses DefaultQueryTimeout.

func (VoltStatement) ExecAsyncTimeout

func (vs VoltStatement) ExecAsyncTimeout(resCons AsyncResponseConsumer, args []driver.Value, timeout time.Duration)

ExecAsyncTimeout asynchronously runs an Exec. Specifies a duration for timeout.

func (VoltStatement) ExecTimeout

func (vs VoltStatement) ExecTimeout(args []driver.Value, timeout time.Duration) (driver.Result, error)

ExecTimeout executes a query that doesn't return rows, such as an INSERT or UPDATE. Specifies a duration for timeout.

func (VoltStatement) NumInput

func (vs VoltStatement) NumInput() int

NumInput returns the number of placeholder parameters.

func (VoltStatement) Query

func (vs VoltStatement) Query(args []driver.Value) (driver.Rows, error)

Query executes a query that may return rows, such as a SELECT. Uses DefaultQueryTimeout.

func (VoltStatement) QueryAsync

func (vs VoltStatement) QueryAsync(rowsCons AsyncResponseConsumer, args []driver.Value)

QueryAsync asynchronously runs a Query. Uses DefaultQueryTimeout.

func (VoltStatement) QueryAsyncTimeout

func (vs VoltStatement) QueryAsyncTimeout(rowsCons AsyncResponseConsumer, args []driver.Value, timeout time.Duration)

QueryAsyncTimeout asynchronously runs a Query. Specifies a duration for timeout.

func (VoltStatement) QueryTimeout

func (vs VoltStatement) QueryTimeout(args []driver.Value, timeout time.Duration) (driver.Rows, error)

QueryTimeout executes a query that may return rows, such as a SELECT. Specifies a duration for timeout.

Jump to

Keyboard shortcuts

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