Documentation ¶
Index ¶
- Constants
- Variables
- func EncodePI(e *wire.Encoder, pi *procedureInvocation) error
- func SearchToken2Partitions(a []token2Partition, token int) (partition int)
- type AsyncResponseConsumer
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)
- func (c *Conn) Close() error
- func (c *Conn) Drain()
- func (c *Conn) DumpConn()
- func (c *Conn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (c *Conn) ExecAsync(resCons AsyncResponseConsumer, query string, args []driver.Value)
- func (c *Conn) ExecAsyncTimeout(resCons AsyncResponseConsumer, query string, args []driver.Value, ...) error
- func (c *Conn) ExecTimeout(query string, args []driver.Value, timeout time.Duration) (driver.Result, error)
- func (c *Conn) Prepare(query string) (driver.Stmt, error)
- func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *Conn) QueryAsync(rowsCons AsyncResponseConsumer, query string, args []driver.Value)
- func (c *Conn) QueryAsyncTimeout(rowsCons AsyncResponseConsumer, query string, args []driver.Value, ...) error
- func (c *Conn) QueryTimeout(query string, args []driver.Value, timeout time.Duration) (driver.Rows, error)
- type ResponseStatus
- type Token2PartitionSlice
- type VoltDriver
- type VoltError
- type VoltResult
- type VoltRows
- func (vr VoltRows) AdvanceRow() bool
- func (vr *VoltRows) AdvanceTable() bool
- func (vr VoltRows) AdvanceToRow(rowIndex int32) bool
- func (vr *VoltRows) AdvanceToTable(tableIndex int16) bool
- func (vr VoltRows) Close() error
- func (vr VoltRows) ColumnCount() int
- func (vr VoltRows) ColumnTypes() []int8
- func (vr VoltRows) Columns() []string
- func (vr VoltRows) GetBigInt(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetBigIntByName(cn string) (interface{}, error)
- func (vr VoltRows) GetDecimal(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetDecimalByName(cn string) (interface{}, error)
- func (vr VoltRows) GetFloat(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetFloatByName(cn string) (interface{}, error)
- func (vr VoltRows) GetInteger(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetIntegerByName(cn string) (interface{}, error)
- func (vr VoltRows) GetSmallInt(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetSmallIntByName(cn string) (interface{}, error)
- func (vr VoltRows) GetString(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetStringByName(cn string) (interface{}, error)
- func (vr VoltRows) GetTimestamp(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetTimestampByName(cn string) (interface{}, error)
- func (vr VoltRows) GetTinyInt(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetTinyIntByName(cn string) (interface{}, error)
- func (vr VoltRows) GetVarbinary(colIndex int16) (interface{}, error)
- func (vr VoltRows) GetVarbinaryByName(cn string) (interface{}, error)
- func (vr VoltRows) Next(dest []driver.Value) (err error)
- type VoltStatement
- func (vs VoltStatement) Close() error
- func (vs VoltStatement) Exec(args []driver.Value) (driver.Result, error)
- func (vs VoltStatement) ExecAsync(resCons AsyncResponseConsumer, args []driver.Value)
- func (vs VoltStatement) ExecAsyncTimeout(resCons AsyncResponseConsumer, args []driver.Value, timeout time.Duration)
- func (vs VoltStatement) ExecTimeout(args []driver.Value, timeout time.Duration) (driver.Result, error)
- func (vs VoltStatement) NumInput() int
- func (vs VoltStatement) Query(args []driver.Value) (driver.Rows, error)
- func (vs VoltStatement) QueryAsync(rowsCons AsyncResponseConsumer, args []driver.Value)
- func (vs VoltStatement) QueryAsyncTimeout(rowsCons AsyncResponseConsumer, args []driver.Value, timeout time.Duration)
- func (vs VoltStatement) QueryTimeout(args []driver.Value, timeout time.Duration) (driver.Rows, error)
Constants ¶
const ( PingHandle = math.MaxInt64 AsyncTopoHandle = PingHandle - 1 )
Handles
const ( PartitionIDBits = 14 // maximum values for the txn id fields PartitionIDMaxValue = (1 << PartitionIDBits) - 1 MPInitPID = PartitionIDMaxValue )
Partitions
const ( BinArrayFormat = 0 JSONFormat = 1 )
Hash Config Format
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. )
const ( // DefaultQueryTimeout time out for queries. DefaultQueryTimeout time.Duration = 2 * time.Minute )
const (
Elastic = "Elastic"
)
Hash Type
Variables ¶
var ErrMissingServerArgument = errors.New("voltdbclient: missing voltdb connection string")
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 SearchToken2Partitions ¶
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 ¶
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 ¶
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 ¶
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) Close ¶
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) Exec ¶
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 ¶
Prepare creates a prepared statement for later queries or executions. The Statement returned by Prepare is bound to this VoltConn.
func (*Conn) Query ¶
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.
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 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.
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 ¶
AdvanceRow advances to the next row of data, returns false if there isn't a next row.
func (*VoltRows) AdvanceTable ¶
AdvanceTable advances to the next table. Returns false if there isn't a next table.
func (VoltRows) AdvanceToRow ¶
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 ¶
AdvanceToTable advances to the table indicated by the index. Returns false if there is no table at the given index.
func (VoltRows) ColumnCount ¶
ColumnCount returns the number of columns in the current table.
func (VoltRows) ColumnTypes ¶
ColumnTypes returns the column types of the columns in the current table.
func (VoltRows) GetBigInt ¶
GetBigInt returns the value of a BIGINT column at the given index in the current row.
func (VoltRows) GetBigIntByName ¶
GetBigIntByName returns the value of a BIGINT column with the given name in the current row.
func (VoltRows) GetDecimal ¶
GetDecimal returns the value of a DECIMAL column at the given index in the current row.
func (VoltRows) GetDecimalByName ¶
GetDecimalByName returns the value of a DECIMAL column with the given name in the current row.
func (VoltRows) GetFloat ¶
GetFloat returns the value of a FLOAT column at the given index in the current row.
func (VoltRows) GetFloatByName ¶
GetFloatByName returns the value of a FLOAT column with the given name in the current row.
func (VoltRows) GetInteger ¶
GetInteger returns the value of a INTEGER column at the given index in the current row.
func (VoltRows) GetIntegerByName ¶
GetIntegerByName returns the value of a INTEGER column with the given name in the current row.
func (VoltRows) GetSmallInt ¶
GetSmallInt returns the value of a SMALLINT column at the given index in the current row.
func (VoltRows) GetSmallIntByName ¶
GetSmallIntByName returns the value of a SMALLINT column with the given name in the current row.
func (VoltRows) GetString ¶
GetString returns the value of a STRING column at the given index in the current row.
func (VoltRows) GetStringByName ¶
GetStringByName returns the value of a STRING column with the given name in the current row.
func (VoltRows) GetTimestamp ¶
GetTimestamp returns the value of a TIMESTAMP column at the given index in the current row.
func (VoltRows) GetTimestampByName ¶
GetTimestampByName returns the value of a TIMESTAMP column with the given name in the current row.
func (VoltRows) GetTinyInt ¶
GetTinyInt returns the value of a TINYINT column at the given index in the current row.
func (VoltRows) GetTinyIntByName ¶
GetTinyIntByName returns the value of a TINYINT column with the given name in the current row.
func (VoltRows) GetVarbinary ¶
GetVarbinary returns the value of a VARBINARY column at the given index in the current row.
func (VoltRows) GetVarbinaryByName ¶
GetVarbinaryByName returns the value of a VARBINARY column with the given name in the current row.
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 ¶
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 ¶
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.