Our Mission Statement
This is Photoshop's version of Loremer Ipsn gravida nibh vel velit auctoregorie sam alquet.Aenean sollicitudin, lorem quis bibendum auci elit consequat ipsutis sem nibh id elit.
Follow Us
New Go language driver available for VoltDB - VoltDB
post-template-default,single,single-post,postid-7927,single-format-standard,mkd-core-1.0,highrise-ver-1.0,,mkd-smooth-page-transitions,mkd-ajax,mkd-grid-1300,mkd-blog-installed,mkd-header-standard,mkd-sticky-header-on-scroll-up,mkd-default-mobile-header,mkd-sticky-up-mobile-header,mkd-dropdown-slide-from-bottom,mkd-dark-header,mkd-header-style-on-scroll,mkd-full-width-wide-menu,mkd-header-standard-in-grid-shadow-disable,mkd-search-dropdown,mkd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-5.1.1,vc_responsive
VoltDB / SQL  / New Go language driver available for VoltDB


New Go language driver available for VoltDB

I’m happy to introduce a fully featured, high-performance VoltDB client for the go language. The golang client is both feature and performance comparable to the VoltDB Java client.

Support of golang Standard Library

The golang standard library provides support for SQL database drivers. This support is represented in two of the standard library’s packages, ‘database/sql’ and ‘database/sql/driver’. The first of these packages, ‘database/sql’, represents the user-facing API for a golang SQL driver. User code is typically written against this API.

The second of these packages, ‘database/sql/driver’, is an API that VoltDB has implemented to provide this driver. This implementation supports the VoltDB wire protocol to communicate with VoltDB server instances.

A set of examples is included with the golang driver. One of these, ‘examples/hello-world/driver_hello_world.go’, demonstrates use of the VoltDB golang client using the standard ‘database/sql’ API. No VoltDB proprietary api is used. The import of the VoltDB client:

import _ "github.com/VoltDB/voltdb-client-go/voltdbclient"

allows the VoltDB client to register itself. Then, a call to ‘Open’:

db, err := sql.Open("voltdb", "localhost:21212")

returns a db/sql.DB object. This object represents a VoltDB connection or pool of connections. From this point the standard API can be used.

VoltDB-specific API

The VoltDB golang client also provides an alternative, VoltDB-specific API. It’s challenging to express all the features of a VoltDB client using golang’s standard ‘database/sql’ API. In particular, there’s no simple way to express asynchronous procedure invocations using the golang standard library API. Asynchronous requests typically perform significantly better than synchronous requests, so the VoltDB-specific API exposes additional behavior.

The VoltDB-specific driver API implements the interfaces present in ‘database/sql/driver’. Fundamentally, this is the same code that is executed when the standard ‘database/sql’ API is used. The distinction is that not all of the VoltDB API is available through the standard ‘database/sql’ API; the VoltDB driver implementation is a superset of this API.

Two simple examples are provided that demonstrate use of the VoltDB-specific API, ‘examples/hello-world/sync_hello_world.go’ and ‘examples/hello-world/async_hello_world.go’. The first demonstrates use of the synchronous API and the second demonstrates use of the asynchronous API.

In both examples, a connection to the VoltDB server is acquired with the statement:

conn, err := voltdbclient.OpenConn("localhost:21212")

Here, ‘conn’ is a reference to the ‘voltdbclient.Conn’ type. The behavior of this type is documented in the VoltDB client go documentation. Note this type implements the golang standard library interface ‘database/sql/driver.Conn’, providing both an implementation of the standard library type and additional VoltDB specific behavior.

The synchronous example, ‘sync_hello_world.go’, then does a synchronous procedure invocation:

rows, err := conn.Query("@AdHoc", []driver.Value{"select * from HELLOWORLD where DIALECT = ?", "French"})

This invocation returns an instance of the standard library type ‘driver.Rows’. ‘driver.Rows’ is an interface; the implementing type is ‘voltdbclient.VoltRows’. The go doc for this type, ‘voltdbclient.VoltRows’, demonstrates that it provides both the ‘driver.Rows’ interface and additional VoltDB-specific behavior.

The asynchronous example, ‘examples/hello-world/async_hello_world.go’, demonstrates use of an asynchronous procedure invocation:

err := conn.QueryAsync(resCons, "HELLOWORLD.select", []driver.Value{key})

This API is not part of the golang standard library. For asynchronous calls, an implementation of the VoltDB interface ‘voltdbclient.AsyncResponseConsumer’ needs to be provided. This type will consume the results of the asynchronous procedure invocation when they become available.


The VoltDB golang client was developed with a number of goals in mind. First, the client is comparable to the Java client in both feature set and in performance.

Also, the golang client implements the golang standard library ‘database/sql/driver’. This means the client can be used through the standard golang API, ‘database/sql’. It also means the ‘database/sql/driver’ interface can be coded against directly.

In addition, interfaces implemented by the VoltDB golang client try to be semantically consistent with the golang standard library. For example, the go doc for the type ‘database/sql.DB’ indicates this object is thread safe. For the VoltDB-specific API, the corresponding object is voltdbclient.Conn; this type also is thread safe.

Finally, the golang VoltDB client provides behavior beyond that specified by the standard golang libraries. This additional behavior is provided through an API that should be familiar to users of the VoltDB Java client.

The go client can be installed with ‘go get’ – find it at ‘go get github.com/VoltDB/voltdb-client-go’.

Please try the golang driver, and let us know what you think. And remember if you provide a code contribution to VoltDB (thank you in advance), don’t forget to sign our CLA.