gocb

package
v0.0.0-...-711f10a Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: GPL-2.0 Imports: 16 Imported by: 0

README

GoDoc

Couchbase Go Client

This is the official Couchbase Go SDK. If you are looking for our previous unofficial prototype Go client library, please see: http://www.github.com/couchbase/go-couchbase.

The Go SDK library allows you to connect to a Couchbase cluster from Go. It is written in pure Go, and uses the included gocbcore library to handle communicating to the cluster over the Couchbase binary protocol.

Source - http://github.com/couchbase/gocb

Documentation - http://developer.couchbase.com/documentation/server/4.0/sdks/go-beta/introduction.html

Bug Tracker - http://www.couchbase.com/issues/browse/GOCBC

Installing

To install the latest development version, run:

go get gopkg.in/couchbaselabs/gocb.v1

License

Copyright 2015 Couchbase Inc.

Licensed under the Apache License, Version 2.0.

See LICENSE for further details.

Documentation

Index

Constants

View Source
const (
	Couchbase = BucketType(0)
	Memcached = BucketType(1)
)
View Source
const (
	NotBounded    = ConsistencyMode(1)
	RequestPlus   = ConsistencyMode(2)
	StatementPlus = ConsistencyMode(3)
)
View Source
const (
	Before = StaleMode(1)
	None   = StaleMode(2)
	After  = StaleMode(3)
)
View Source
const (
	Ascending  = SortOrder(1)
	Descending = SortOrder(2)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendOp

type AppendOp struct {
	Key   string
	Value string
	Cas   Cas
	Err   error
	// contains filtered or unexported fields
}

type Bucket

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

An interface representing a single bucket within a cluster.

func (*Bucket) Append

func (b *Bucket) Append(key, value string) (Cas, error)

Appends a string value to a document.

func (*Bucket) AppendDura

func (b *Bucket) AppendDura(key, value string, replicateTo, persistTo uint) (Cas, error)

Appends a string value to a document. Additionally checks document durability.

func (*Bucket) Close

func (b *Bucket) Close()

func (*Bucket) Counter

func (b *Bucket) Counter(key string, delta, initial int64, expiry uint32) (uint64, Cas, error)

Performs an atomic addition or subtraction for an integer document.

func (*Bucket) CounterDura

func (b *Bucket) CounterDura(key string, delta, initial int64, expiry uint32, replicateTo, persistTo uint) (uint64, Cas, error)

Performs an atomic addition or subtraction for an integer document. Additionally checks document durability.

func (*Bucket) Do

func (b *Bucket) Do(ops []BulkOp) error

func (*Bucket) DurabilityPollTimeout

func (b *Bucket) DurabilityPollTimeout() time.Duration

func (*Bucket) DurabilityTimeout

func (b *Bucket) DurabilityTimeout() time.Duration

func (*Bucket) ExecuteN1qlQuery

func (b *Bucket) ExecuteN1qlQuery(q *N1qlQuery, params interface{}) (ViewResults, error)

Performs a spatial query and returns a list of rows or an error.

func (*Bucket) ExecuteSpatialQuery

func (b *Bucket) ExecuteSpatialQuery(q *SpatialQuery) (ViewResults, error)

Performs a spatial query and returns a list of rows or an error.

func (*Bucket) ExecuteViewQuery

func (b *Bucket) ExecuteViewQuery(q *ViewQuery) (ViewResults, error)

Performs a view query and returns a list of rows or an error.

func (*Bucket) Get

func (b *Bucket) Get(key string, valuePtr interface{}) (Cas, error)

Retrieves a document from the bucket

func (*Bucket) GetAndLock

func (b *Bucket) GetAndLock(key string, lockTime uint32, valuePtr interface{}) (Cas, error)

Locks a document for a period of time, providing exclusive RW access to it.

func (*Bucket) GetAndTouch

func (b *Bucket) GetAndTouch(key string, expiry uint32, valuePtr interface{}) (Cas, error)

Retrieves a document and simultaneously updates its expiry time.

func (*Bucket) GetReplica

func (b *Bucket) GetReplica(key string, valuePtr interface{}, replicaIdx int) (Cas, error)

Returns the value of a particular document from a replica server.

func (*Bucket) Insert

func (b *Bucket) Insert(key string, value interface{}, expiry uint32) (Cas, error)

Inserts a new document to the bucket.

func (*Bucket) InsertDura

func (b *Bucket) InsertDura(key string, value interface{}, expiry uint32, replicateTo, persistTo uint) (Cas, error)

Inserts a new document to the bucket. Additionally checks document durability.

func (*Bucket) Internal

func (b *Bucket) Internal() *bucketInternal

Internal methods, not safe to be consumed by third parties.

func (*Bucket) InvalidateQueryCache

func (b *Bucket) InvalidateQueryCache()

func (*Bucket) IoRouter

func (b *Bucket) IoRouter() *gocbcore.Agent

func (*Bucket) Manager

func (b *Bucket) Manager(username, password string) *BucketManager

func (*Bucket) OperationTimeout

func (b *Bucket) OperationTimeout() time.Duration

func (*Bucket) Prepend

func (b *Bucket) Prepend(key, value string) (Cas, error)

Prepends a string value to a document.

func (*Bucket) PrependDura

func (b *Bucket) PrependDura(key, value string, replicateTo, persistTo uint) (Cas, error)

Prepends a string value to a document. Additionally checks document durability.

func (*Bucket) Remove

func (b *Bucket) Remove(key string, cas Cas) (Cas, error)

Removes a document from the bucket.

func (*Bucket) RemoveDura

func (b *Bucket) RemoveDura(key string, cas Cas, replicateTo, persistTo uint) (Cas, error)

Removes a document from the bucket. Additionally checks document durability.

func (*Bucket) Replace

func (b *Bucket) Replace(key string, value interface{}, cas Cas, expiry uint32) (Cas, error)

Replaces a document in the bucket.

func (*Bucket) ReplaceDura

func (b *Bucket) ReplaceDura(key string, value interface{}, cas Cas, expiry uint32, replicateTo, persistTo uint) (Cas, error)

Replaces a document in the bucket. Additionally checks document durability.

func (*Bucket) SetDurabilityPollTimeout

func (b *Bucket) SetDurabilityPollTimeout(timeout time.Duration)

func (*Bucket) SetDurabilityTimeout

func (b *Bucket) SetDurabilityTimeout(timeout time.Duration)

func (*Bucket) SetOperationTimeout

func (b *Bucket) SetOperationTimeout(timeout time.Duration)

func (*Bucket) SetTranscoder

func (b *Bucket) SetTranscoder(transcoder Transcoder)

func (*Bucket) Touch

func (b *Bucket) Touch(key string, cas Cas, expiry uint32) (Cas, error)

Touches a document, specifying a new expiry time for it.

func (*Bucket) TouchDura

func (b *Bucket) TouchDura(key string, cas Cas, expiry uint32, replicateTo, persistTo uint) (Cas, error)

Touches a document, specifying a new expiry time for it. Additionally checks document durability.

func (*Bucket) Unlock

func (b *Bucket) Unlock(key string, cas Cas) (Cas, error)

Unlocks a document which was locked with GetAndLock.

func (*Bucket) Upsert

func (b *Bucket) Upsert(key string, value interface{}, expiry uint32) (Cas, error)

Inserts or replaces a document in the bucket.

func (*Bucket) UpsertDura

func (b *Bucket) UpsertDura(key string, value interface{}, expiry uint32, replicateTo, persistTo uint) (Cas, error)

Inserts or replaces a document in the bucket. Additionally checks document durability.

type BucketManager

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

func (*BucketManager) Flush

func (bm *BucketManager) Flush() error

func (*BucketManager) GetDesignDocument

func (bm *BucketManager) GetDesignDocument(name string) (*DesignDocument, error)

func (*BucketManager) GetDesignDocuments

func (bm *BucketManager) GetDesignDocuments() ([]*DesignDocument, error)

func (*BucketManager) InsertDesignDocument

func (bm *BucketManager) InsertDesignDocument(ddoc *DesignDocument) error

func (*BucketManager) RemoveDesignDocument

func (bm *BucketManager) RemoveDesignDocument(name string) error

func (*BucketManager) UpsertDesignDocument

func (bm *BucketManager) UpsertDesignDocument(ddoc *DesignDocument) error

type BucketSettings

type BucketSettings struct {
	FlushEnabled  bool
	IndexReplicas bool
	Name          string
	Password      string
	Quota         int
	Replicas      int
	Type          BucketType
}

type BucketType

type BucketType int

type BulkOp

type BulkOp interface {
	// contains filtered or unexported methods
}

type Cas

type Cas gocbcore.Cas

type Cluster

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

func Connect

func Connect(connSpecStr string) (*Cluster, error)

func (*Cluster) ConnectTimeout

func (c *Cluster) ConnectTimeout() time.Duration

func (*Cluster) Manager

func (c *Cluster) Manager(username, password string) *ClusterManager

func (*Cluster) OpenBucket

func (c *Cluster) OpenBucket(bucket, password string) (*Bucket, error)

func (*Cluster) OpenStreamingBucket

func (c *Cluster) OpenStreamingBucket(streamName, bucket, password string) (*StreamingBucket, error)

func (*Cluster) ServerConnectTimeout

func (c *Cluster) ServerConnectTimeout() time.Duration

func (*Cluster) SetConnectTimeout

func (c *Cluster) SetConnectTimeout(timeout time.Duration)

func (*Cluster) SetServerConnectTimeout

func (c *Cluster) SetServerConnectTimeout(timeout time.Duration)

type ClusterManager

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

func (*ClusterManager) GetBuckets

func (cm *ClusterManager) GetBuckets() ([]*BucketSettings, error)

func (*ClusterManager) InsertBucket

func (cm *ClusterManager) InsertBucket(settings *BucketSettings) error

func (*ClusterManager) RemoveBucket

func (cm *ClusterManager) RemoveBucket(name string) error

func (*ClusterManager) UpdateBucket

func (cm *ClusterManager) UpdateBucket(settings *BucketSettings) error

type ConsistencyMode

type ConsistencyMode int

type CounterOp

type CounterOp struct {
	Key     string
	Delta   int64
	Initial int64
	Expiry  uint32
	Cas     Cas
	Value   uint64
	Err     error
	// contains filtered or unexported fields
}

type DefaultTranscoder

type DefaultTranscoder struct {
}

func (DefaultTranscoder) Decode

func (t DefaultTranscoder) Decode(bytes []byte, flags uint32, out interface{}) error

func (DefaultTranscoder) Encode

func (t DefaultTranscoder) Encode(value interface{}) ([]byte, uint32, error)

type DesignDocument

type DesignDocument struct {
	Name         string          `json:"-"`
	Views        map[string]View `json:"views,omitempty"`
	SpatialViews map[string]View `json:"spatial,omitempty"`
}

type GetAndTouchOp

type GetAndTouchOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

type GetOp

type GetOp struct {
	Key   string
	Value interface{}
	Cas   Cas
	Err   error
	// contains filtered or unexported fields
}

type InsertOp

type InsertOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

type MutationToken

type MutationToken gocbcore.MutationToken

type N1qlQuery

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

func NewN1qlQuery

func NewN1qlQuery(statement string) *N1qlQuery

func (*N1qlQuery) AdHoc

func (nq *N1qlQuery) AdHoc(adhoc bool) *N1qlQuery

func (*N1qlQuery) Consistency

func (nq *N1qlQuery) Consistency(stale ConsistencyMode) *N1qlQuery

func (*N1qlQuery) Custom

func (nq *N1qlQuery) Custom(name, value string) *N1qlQuery

type PrependOp

type PrependOp struct {
	Key   string
	Value string
	Cas   Cas
	Err   error
	// contains filtered or unexported fields
}

type QueryResults

type QueryResults interface {
	One(valuePtr interface{}) error
	Next(valuePtr interface{}) bool
	Close() error
}

type RemoveOp

type RemoveOp struct {
	Key string
	Cas Cas
	Err error
	// contains filtered or unexported fields
}

type ReplaceOp

type ReplaceOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

type SortOrder

type SortOrder int

type SpatialQuery

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

func NewSpatialQuery

func NewSpatialQuery(ddoc, name string) *SpatialQuery

func (*SpatialQuery) Bbox

func (vq *SpatialQuery) Bbox(bounds []float64) *SpatialQuery

func (*SpatialQuery) Custom

func (vq *SpatialQuery) Custom(name, value string) *SpatialQuery

func (*SpatialQuery) Development

func (vq *SpatialQuery) Development(val bool) *SpatialQuery

func (*SpatialQuery) Limit

func (vq *SpatialQuery) Limit(num uint) *SpatialQuery

func (*SpatialQuery) Skip

func (vq *SpatialQuery) Skip(num uint) *SpatialQuery

func (*SpatialQuery) Stale

func (vq *SpatialQuery) Stale(stale StaleMode) *SpatialQuery

type StaleMode

type StaleMode int

type StreamingBucket

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

func (*StreamingBucket) IoRouter

func (b *StreamingBucket) IoRouter() *gocbcore.Agent

type TouchOp

type TouchOp struct {
	Key    string
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

type Transcoder

type Transcoder interface {
	Decode([]byte, uint32, interface{}) error
	Encode(interface{}) ([]byte, uint32, error)
}

type UpsertOp

type UpsertOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

type View

type View struct {
	Map    string `json:"map,omitempty"`
	Reduce string `json:"reduce,omitempty"`
}

type ViewQuery

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

func NewViewQuery

func NewViewQuery(ddoc, name string) *ViewQuery

func (*ViewQuery) Custom

func (vq *ViewQuery) Custom(name, value string) *ViewQuery

func (*ViewQuery) Development

func (vq *ViewQuery) Development(val bool) *ViewQuery

func (*ViewQuery) Group

func (vq *ViewQuery) Group(useGrouping bool) *ViewQuery

func (*ViewQuery) GroupLevel

func (vq *ViewQuery) GroupLevel(groupLevel uint) *ViewQuery

func (*ViewQuery) IdRange

func (vq *ViewQuery) IdRange(start, end string) *ViewQuery

func (*ViewQuery) Key

func (vq *ViewQuery) Key(key interface{}) *ViewQuery

func (*ViewQuery) Keys

func (vq *ViewQuery) Keys(keys []interface{}) *ViewQuery

func (*ViewQuery) Limit

func (vq *ViewQuery) Limit(num uint) *ViewQuery

func (*ViewQuery) Order

func (vq *ViewQuery) Order(order SortOrder) *ViewQuery

func (*ViewQuery) Range

func (vq *ViewQuery) Range(start, end interface{}, inclusive_end bool) *ViewQuery

func (*ViewQuery) Reduce

func (vq *ViewQuery) Reduce(reduce bool) *ViewQuery

func (*ViewQuery) Skip

func (vq *ViewQuery) Skip(num uint) *ViewQuery

func (*ViewQuery) Stale

func (vq *ViewQuery) Stale(stale StaleMode) *ViewQuery

type ViewResults

type ViewResults interface {
	One(valuePtr interface{}) error
	Next(valuePtr interface{}) bool
	Close() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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