Both Couchbase and Go have similar goals for scalability and ease of use. The natural alignment results in a great pairing between Couchbase and Go. Application developers need scalable data management systems like Couchbase for the systems they design, so today I’m excited to announce Couchbase is introducing a Go SDK for easy scalability and simple integration with your own Go development projects.

There are several reasons we at Couchbase love Go:

  1. Go makes it easy to build efficient applications ready for high concurrency.
  2. Go makes it easy to work with JSON when building simple, reliable, efficient applications. 
  3. Go is a well documented, powerful platform intended to keep the syntax and standard library simple allowing the community to build out the rest. 

Let’s look at each of these.

High Concurrency

Go is focused on enabling developers with simple constructs that make it easy to assemble highly-concurrent programs. Through this, applications written in Go are able to scale with minimal effort. As hardware and distributed system architectures evolve, programs built in Go have the DNA to efficiently use those resources to scale to even more users. Couchbase has similar goals. We want to enable the database chosen by the application developer to scale with minimal effort. In Go, building for scale is primarily done through primitives known as goroutines, which express logic to execute in parallel, and channels, which safely moves data across the parallel logic.

The Couchbase SDK for Go works well with these constructs. From the outset, we looked to give the Go application developer an API surface area that fits inside an application using goroutines and channels. The SDK is designed to easily work with the concurrency expressed by the application developer while not adding overhead in its own management of the work asked of it. Net result? With minimal effort, the application gets the benefit of all of the performance and scale of the Couchbase Server cluster.  The Go SDK, abstracts away the details of what needs to happen when scaling the Couchbase Server cluster. 

Ease of Development

Another way our Go SDK seamlessly blends with the philosophy around Go is by being simple to setup and use in an application. Recognizing that a Go application will define the data structures it will work with across goroutines and channels, the Couchbase SDK for Go gives developers a simple way of expressing how to query and store data in a Couchbase Server cluster. Go has excellent support for mapping JSON to data types in Go. The Go SDK leverages this in the actions developers request of it.  When querying or adding data, the SDK will marshal and unmarshal the JSON responses into the Go structures defined by the application.

The Couchbase SDK for Go supports new features in Couchbase Server that make developing applications easy. Couchbase's new query language N1QL extends SQL to work with JSON documents allowing developers to easily query in a familiar way.  With N1QL’s ability to easily query JSON  structured data at the fingertips of a Go developer, the acts of finding, manipulating and storing data become easy.

Simple on the Surface, but Extensible

The Go community strives for simplicity by keeping the standard library and syntax simple at the surface while not hiding primitives from those who need them. Using the Go community’s desire for simplicity with deep capabilities, we created two layers in the Go SDK.

First, to satisfy the developer looking for straightforward ability to work with JSON mapped to Go language structures, we built a simple interface, known as gocb, that gives a developer easy-to-understand, type-safe operations. This interface also integrates quickly into the synchronous goroutine framework in Go.

There are some situations where a developer needs to integrate Couchbase into a larger framework which is expected to be used by other developers. An example might be a new application framework needing a pure, asynchronous interface or a reactive component in the middle of the architecture moving data between systems. Those developers may need to interact closely at the lowest levels of how the Couchbase SDK interacts with the Couchbase Server cluster. There may also be times that developers want to skip past data marshaling to save that small bit of extra processing or a desire to move to a 100 percent asynchronous interface for IO. The needs of each of these cases is met by the gocbcore layer in the Couchbase SDK for Go.

What’s Next

Software is continuously evolving and we will continue to work with the improvements coming out of the Go community. Google has made great strides with Go 1.5’s memory management and development ease. We expect the new developer tooling and redesign of memory management to be things that will help us with future versions of Couchbase Server while those developing their own Go programs can take advantage of the changes immediately with the Couchbase SDK for Go, which supports Go 1.5 today.

And for Couchbase components using Go? That future is being built now. We have a number of new projects published as Open Source that we expect to arrive in the next few releases of Couchbase Server and Couchbase Mobile. Most of those projects are written in Go as well.

We’re excited to see what developers build with our new Couchbase SDK for Go.

You will find code samples and locations for the bits and the docs from Brett Lawson's blog on the GA.  Brett is the lead engineer on the Go SDK.


Posted by Matt Ingenthron, Senior Director, SDK Engineering, Couchbase

Matt Ingenthron is the Senior Director in Engineering at Couchbase where he focuses on the developer interface across SDKs, connectors and other projects. He has been a contributor to the memcached project, one of the maintainers of the Java spymemcached client, and a core developer on Couchbase.

Leave a reply