I am happy to announce the first Developer Preview of our official Go SDK (gocb) today.

 

While in the past, we have had the go-couchbase project which does provide access to many of Couchbase’s features, it was primarily intended to be used internally to our company.  gocb marks the first preview of an upcoming release designed and developed specifically to meet the goals of Go developers using Couchbase.

 

The gocb project is implemented as a set of blocking methods which can be used concurrently from as many goroutines as desired.  It is suggested that you distribute your workload across as many goroutines that fit within your application design to maximize the parallelism of the library.

 

You can find an API reference for the gocb project at: http://godoc.org/github.com/couchbaselabs/gocb/.

 

Performing Basic Operations

 

Performing View Queries

 

Registro em log

While the logging that is available within gocb is still in its infancy, it can provide a great deal of useful information for debugging.  Setting up gocbcore to log to the console is quite trivial using a built in logger object.  Make sure to only call this once at the beginning of your application though as the logger is assumed to be immutable once any other methods are invoked.

 

Go SDK Architecture

The gocb library

The gocb library is our developer oriented library intended to provide a simple and easy to use interface to users.  This library implements a blocking API which exposes all of our developer oriented functionality to you.

 

The gocbcore library

The gocbcore library is our internal library which provides all of the network and smart management functionality of the client.  This library provides is used by gocb internally.

gocbcore implements a mostly lockless method of dispatching operations, giving your application the ability to easily distribute the load across as many cores as servers in your cluster.  This means better performance, and the ability to safely use the client across as many goroutines as you desire without incuring any performance penalty.

Autor

A ordem da postagem em relação a outras postagens. Brett Lawson, Principal Software Engineer, Couchbase

Brett Lawson is a Principal Software Engineer at Couchbase. Brett is responsible for the design and development of the Couchbase Node.js and PHP clients as well as playing a role in the design and development of the C library, libcouchbase.

23 Comentários

    1. This is correct. While having a Disconnect ability will be helpful for some edge cases, the appropriate way to handle Bucket connections is to create them during application initialization and use the same instance from throughout your application (Bucket methods are safe and performant from as many goroutines as you deem necessary).

          1. thanks,
            but i need the pool to avoid the over-use of server resources,
            any way i think closing the connection may be useful to be exported as a method.

          2. Hey, could you elaborate on how pooling the Bucket instances would reduce serve resource usage? In fact, I suspect the result may be the opposite as Bucket connections are rather expensive in terms of the resources used and are highly optimized to perform well across numerous threads.

          3. thanks for reply,
            but i mean it will reduce the usage of resources for my server application, not the database server
            any way it is a good point to support the closing method

  1. If an operation that persists data to a node over an open
    connection fails in the case of node failure, will the SDK automatically attempt
    to establish a connection to the next node that is promoted? Or, should my
    application logic instead capture specific connection errors, and respond
    accordingly by explicitly attempting to reconnect?

    1. The application attempts to retry storage operations only as long as it is safe to do so. In the case of a node failure once the operation has already been dispatched on the network, the error will be propagated to the user to be handled as the operations true status is unknown at that point and automatically retrying could be problematic.

  2. I notice that if I add a document as follows:

    bucket.Upsert(id, &myStruct, 0)

    And then invoke a view as per your example, the row variable contains an ID that has no relevance. I\’m not sure where it comes from, but it is not equal to the ID that I set during upsert.

    If I reconnect, and then invoke the view again, all works as expected.

    I\’ve tried setting a wait period before calling the view, to no avail. I\’m running a single node on a DEV machine.

  3. Something wrong with library :(

    $ go get gopkg.in/couchbaselabs/gocb.v0

    # gopkg.in/couchbaselabs/gocb.v0

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.UnlockCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.TouchCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.RemoveCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.StoreCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.StoreCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.StoreCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.StoreCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCasCallback) to type gocbcore.StoreCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCtrCallback) to type gocbcore.CounterCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… cannot convert cb (type ioCtrCallback) to type gocbcore.CounterCallback

    /Users/alec/go/src/gopkg.in/couchbaselabs/gocb.v0… too many errors

Posição vertical a partir do topo para iniciar o corte como uma porcentagem da altura da imagem.