aerospike

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2015 License: Apache-2.0 Imports: 24 Imported by: 0

README

Aerospike Go Client

An Aerospike library for Go.

This library is compatible with Go 1.2+ and supports the following operating systems: Linux, Mac OS X (Windows builds are possible, but untested)

Please refer to CHANGELOG.md if you encounter breaking changes.

Usage:

The following is a very simple example of CRUD operations in an Aerospike database.

package main

import (
  "fmt"

  . "github.com/aerospike/aerospike-client-go"
)

func panicOnError(err error) {
  if err != nil {
    panic(err)
  }
}

func main() {
  // define a client to connect to
  client, err := NewClient("127.0.0.1", 3000)
  panicOnError(err)

  key, err := NewKey("test", "aerospike", "key")
  panicOnError(err)

  // define some bins with data
  bins := BinMap{
    "bin1": 42,
    "bin2": "An elephant is a mouse with an operating system",
    "bin3": []interface{}{"Go", 2009},
  }

  // write the bins
  err = client.Put(nil, key, bins)
  panicOnError(err)

  // read it back!
  rec, err := client.Get(nil, key)
  panicOnError(err)

  fmt.Printf("%#v\n", *rec)

  // delete the key, and check if key exists
  existed, err := client.Delete(nil, key)
  panicOnError(err)
  fmt.Printf("Record existed before delete? %v\n", existed)
}

More examples illustrating the use of the API are located in the examples directory.

Details about the API are available in the docs directory.

Prerequisites

Go version v1.2+ is required. (It is possible to build the code in Go versions prior to 1.2, but our testing library depends on v1.2)

To install the latest stable version of Go, visit http://golang.org/dl/

Aerospike Go client implements the wire protocol, and does not depend on the C client. It is goroutine friendly, and works asynchronously.

Supported operating systems:

  • Major Linux distributions (Ubuntu, Debian, Redhat)
  • Mac OS X
  • Windows (untested)

Installation:

  1. Install Go 1.2+ and setup your environment as Documented here.
  2. Get the client in your GOPATH : go get github.com/aerospike/aerospike-client-go
  • To update the client library: go get -u github.com/aerospike/aerospike-client-go

Using gopkg.io is also supported.

Some Hints:
  • To run a go program directly: go run <filename.go>
  • to build: go build -o <output> <filename.go>
  • example: go build -o benchmark tools/benchmark/benchmark.go

Performance Tweaking

We are bending all efforts to improve the client's performance. In out reference benchmarks, Go client performs almost as good as the C client.

To read about performance variables, please refer to docs/performance.md

Tests

This library is packaged with a number of tests. Tests require Ginkgo and Gomega library.

Before running the tests, you need to update the dependencies:

$ go get .

To run all the test cases with race detection:

$ ginkgo -r -race

Examples

A variety of example applications are provided in the examples directory. See the examples/README.md for details.

Tools

A variety of clones of original tools are provided in the tools directory. They show how to use more advanced features of the library to reimplement the same functionality in a more concise way.

Benchmarks

Benchmark utility is provided in the tools/benchmark directory. See the tools/benchmark/README.md for details.

API Documentation

API documentation is available in the docs directory.

License

The Aerospike Go Client is made available under the terms of the Apache License, Version 2, as stated in the file LICENSE.

Individual files may be made available under their own specific license, all compatible with Apache License, Version 2. Please see individual files for details.

Documentation

Index

Constants

View Source
const (
	// Involve a single replica in the operation.
	CONSISTENCY_ONE = iota

	// Involve all replicas in the operation.
	CONSISTENCY_ALL
)

Variables

This section is empty.

Functions

func RequestInfo

func RequestInfo(conn *Connection, names ...string) (map[string]string, error)

RequestInfo gets info values by name from the specified connection.

func RequestNodeInfo added in v1.0.1

func RequestNodeInfo(node *Node, name ...string) (map[string]string, error)

RequestNodeInfo gets info values by name from the specified database server node.

func RequestNodeStats added in v1.0.1

func RequestNodeStats(node *Node) (map[string]string, error)

RequestNodeStats returns statistics for the specified node as a map

func SetCommandBufferPool added in v1.0.1

func SetCommandBufferPool(poolSize, initBufSize, maxBufferSize int)

SetCommandBufferPool can be used to customize the command Buffer Pool parameters to calibrate the pool for different workloads

Types

type AdminCommand added in v1.3.0

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

type AdminPolicy added in v1.3.0

type AdminPolicy struct {

	// User administration command socket timeout in milliseconds.
	// Default is one second timeout.
	Timeout time.Duration
}

Policy attributes used for user administration commands.

func NewAdminPolicy added in v1.3.0

func NewAdminPolicy() *AdminPolicy

NewAdminPolicy generates a new AdminPolicy with default values.

type AerospikeBlob

type AerospikeBlob interface {
	// EncodeBlob returns a byte slice representing the encoding of the
	// receiver for transmission to a Decoder, usually of the same
	// concrete type.
	EncodeBlob() ([]byte, error)
}

AerospikeBlob defines an interface to automatically encode an object to a []byte.

type BasePolicy

type BasePolicy struct {
	Policy

	// Priority of request relative to other transactions.
	// Currently, only used for scans.
	Priority Priority //= Priority.DEFAULT;

	// How replicas should be consulted in a read operation to provide the desired
	// consistency guarantee. Default to allowing one replica to be used in the
	// read operation.
	ConsistencyLevel ConsistencyLevel //= CONSISTENCY_ONE

	// Timeout specifies transaction timeout.
	// This timeout is used to set the socket timeout and is also sent to the
	// server along with the transaction in the wire protocol.
	// Default to no timeout (0).
	Timeout time.Duration

	// MaxRetries determines maximum number of retries before aborting the current transaction.
	// A retry is attempted when there is a network error other than timeout.
	// If maxRetries is exceeded, the abort will occur even if the timeout
	// has not yet been exceeded.
	MaxRetries int //= 2;

	// SleepBetweenReplies determines duration to sleep between retries if a transaction fails and the
	// timeout was not exceeded.  Enter zero to skip sleep.
	SleepBetweenRetries time.Duration //= 500ms;
}

BasePolicy excapsulates parameters for transaction policy attributes used in all database operation calls.

func NewPolicy

func NewPolicy() *BasePolicy

NewPolicy generates a new BasePolicy instance with default values.

func (*BasePolicy) GetBasePolicy

func (p *BasePolicy) GetBasePolicy() *BasePolicy

GetBasePolicy returns embedded BasePolicy in all types that embed this struct.

type BaseTask added in v1.0.1

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

BaseTask is used to poll for server task completion.

func NewTask added in v1.0.1

func NewTask(cluster *Cluster, done bool) *BaseTask

NewTask initializes task with fields needed to query server nodes.

type Bin

type Bin struct {
	// Bin name. Current limit is 14 characters.
	Name string

	// Bin value.
	Value Value
}

Bin encapsulates a field name/value pair.

func NewBin

func NewBin(name string, value interface{}) *Bin

NewBin generates a new Bin instance, specifying bin name and string value. For servers configured as "single-bin", enter an empty name.

func (*Bin) String

func (bn *Bin) String() string

String implements Stringer interface.

type BinMap

type BinMap map[string]interface{}

BinMap is used to define a map of bin names to values.

type BytesValue

type BytesValue []byte

BytesValue encapsulates an array of bytes.

func NewBlobValue

func NewBlobValue(object AerospikeBlob) BytesValue

NewBlobValue accepts an AerospikeBlob interface, and automatically converts it to a BytesValue. If Encode returns an err, it will panic.

func NewBytesValue

func NewBytesValue(bytes []byte) BytesValue

NewBytesValue generates a ByteValue instance.

func (BytesValue) GetObject

func (vl BytesValue) GetObject() interface{}

GetObject returns original value as an interface{}.

func (BytesValue) GetType

func (vl BytesValue) GetType() int

GetType returns wire protocol value type.

func (BytesValue) String

func (vl BytesValue) String() string

String implements Stringer interface.

type Client

type Client struct {

	// DefaultPolicy is used for all read commands without a specific policy.
	DefaultPolicy *BasePolicy
	// DefaultWritePolicy is used for all write commands without a specific policy.
	DefaultWritePolicy *WritePolicy
	// DefaultScanPolicy is used for all query commands without a specific policy.
	DefaultScanPolicy *ScanPolicy
	// DefaultQueryPolicy is used for all scan commands without a specific policy.
	DefaultQueryPolicy *QueryPolicy
	// DefaultAdminPolicy is used for all security commands without a specific policy.
	DefaultAdminPolicy *AdminPolicy
	// contains filtered or unexported fields
}

Client encapsulates an Aerospike cluster. All database operations are available against this object.

func NewClient

func NewClient(hostname string, port int) (*Client, error)

NewClient generates a new Client instance.

func NewClientWithPolicy

func NewClientWithPolicy(policy *ClientPolicy, hostname string, port int) (*Client, error)

NewClientWithPolicy generates a new Client using the specified ClientPolicy. If the policy is nil, the default relevant policy will be used.

func NewClientWithPolicyAndHost

func NewClientWithPolicyAndHost(policy *ClientPolicy, hosts ...*Host) (*Client, error)

NewClientWithPolicyAndHost generates a new Client the specified ClientPolicy and sets up the cluster using the provided hosts. If the policy is nil, the default relevant policy will be used.

func (*Client) Add

func (clnt *Client) Add(policy *WritePolicy, key *Key, binMap BinMap) error

Add adds integer bin values to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for integer values. If the policy is nil, the default relevant policy will be used.

func (*Client) AddBins

func (clnt *Client) AddBins(policy *WritePolicy, key *Key, bins ...*Bin) error

AddBins works the same as Add, but avoids BinMap allocation and iteration.

func (*Client) Append

func (clnt *Client) Append(policy *WritePolicy, key *Key, binMap BinMap) error

Append appends bin value's string to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call only works for string and []byte values. If the policy is nil, the default relevant policy will be used.

func (*Client) AppendBins

func (clnt *Client) AppendBins(policy *WritePolicy, key *Key, bins ...*Bin) error

AppendBins works the same as Append, but avoids BinMap allocation and iteration.

func (*Client) BatchExists added in v1.0.1

func (clnt *Client) BatchExists(policy *BasePolicy, keys []*Key) ([]bool, error)

BatchExists determines if multiple record keys exist in one batch request. The returned boolean array is in positional order with the original key array order. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) BatchGet added in v1.0.1

func (clnt *Client) BatchGet(policy *BasePolicy, keys []*Key, binNames ...string) ([]*Record, error)

BatchGet reads multiple record headers and bins for specified keys in one batch request. The returned records are in positional order with the original key array order. If a key is not found, the positional record will be nil. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) BatchGetHeader added in v1.0.1

func (clnt *Client) BatchGetHeader(policy *BasePolicy, keys []*Key) ([]*Record, error)

BatchGetHeader reads multiple record header data for specified keys in one batch request. The returned records are in positional order with the original key array order. If a key is not found, the positional record will be nil. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) ChangePassword added in v1.3.0

func (clnt *Client) ChangePassword(policy *AdminPolicy, user string, password string) error

Change user's password. Clear-text password will be hashed using bcrypt before sending to server.

func (*Client) Close

func (clnt *Client) Close()

Close closes all client connections to database server nodes.

func (*Client) CreateIndex added in v1.0.1

func (clnt *Client) CreateIndex(
	policy *WritePolicy,
	namespace string,
	setName string,
	indexName string,
	binName string,
	indexType IndexType,
) (*IndexTask, error)

CreateIndex creates a secondary index. This asynchronous server call will return before the command is complete. The user can optionally wait for command completion by using the returned IndexTask instance. This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) CreateUser added in v1.3.0

func (clnt *Client) CreateUser(policy *AdminPolicy, user string, password string, roles []string) error

Create user with password and roles. Clear-text password will be hashed using bcrypt before sending to server.

func (*Client) Delete

func (clnt *Client) Delete(policy *WritePolicy, key *Key) (bool, error)

Delete deletes a record for specified key. The policy specifies the transaction timeout. If the policy is nil, the default relevant policy will be used.

func (*Client) DropIndex added in v1.0.1

func (clnt *Client) DropIndex(
	policy *WritePolicy,
	namespace string,
	setName string,
	indexName string,
) error

DropIndex deletes a secondary index. This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) DropUser added in v1.3.0

func (clnt *Client) DropUser(policy *AdminPolicy, user string) error

Remove user from cluster.

func (*Client) Execute added in v1.0.1

func (clnt *Client) Execute(policy *WritePolicy, key *Key, packageName string, functionName string, args ...Value) (interface{}, error)

Execute executes a user defined function on server and return results. The function operates on a single record. The package name is used to locate the udf file location:

udf file = <server udf dir>/<package name>.lua

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) ExecuteUDF added in v1.0.1

func (clnt *Client) ExecuteUDF(policy *QueryPolicy,
	statement *Statement,
	packageName string,
	functionName string,
	functionArgs ...Value,
) (*ExecuteTask, error)

ExecuteUDF applies user defined function on records that match the statement filter. Records are not returned to the client. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned ExecuteTask instance.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) Exists

func (clnt *Client) Exists(policy *BasePolicy, key *Key) (bool, error)

Exists determine if a record key exists. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) Get

func (clnt *Client) Get(policy *BasePolicy, key *Key, binNames ...string) (*Record, error)

Get reads a record header and bins for specified key. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) GetHeader

func (clnt *Client) GetHeader(policy *BasePolicy, key *Key) (*Record, error)

GetHeader reads a record generation and expiration only for specified key. Bins are not read. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) GetLargeList added in v1.0.1

func (clnt *Client) GetLargeList(policy *WritePolicy, key *Key, binName string, userModule string) *LargeList

GetLargeList initializes large list operator. This operator can be used to create and manage a list within a single bin.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) GetLargeMap added in v1.0.1

func (clnt *Client) GetLargeMap(policy *WritePolicy, key *Key, binName string, userModule string) *LargeMap

GetLargeMap initializes a large map operator. This operator can be used to create and manage a map within a single bin.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used. NOTICE: DEPRECATED ON SERVER. Will be removed in future.

func (*Client) GetLargeSet added in v1.0.1

func (clnt *Client) GetLargeSet(policy *WritePolicy, key *Key, binName string, userModule string) *LargeSet

GetLargeSet initializes large set operator. This operator can be used to create and manage a set within a single bin.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used. NOTICE: DEPRECATED ON SERVER. Will be removed in future.

func (*Client) GetLargeStack added in v1.0.1

func (clnt *Client) GetLargeStack(policy *WritePolicy, key *Key, binName string, userModule string) *LargeStack

GetLargeStack initializes large stack operator. This operator can be used to create and manage a stack within a single bin.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used. NOTICE: DEPRECATED ON SERVER. Will be removed in future.

func (*Client) GetNodeNames

func (clnt *Client) GetNodeNames() []string

GetNodeNames returns a list of active server node names in the cluster.

func (*Client) GetNodes

func (clnt *Client) GetNodes() []*Node

GetNodes returns an array of active server nodes in the cluster.

func (*Client) GetObject added in v1.4.0

func (clnt *Client) GetObject(policy *BasePolicy, key *Key, obj interface{}) error

GetObject reads a record for specified key and puts the result into the provided object. The policy can be used to specify timeouts. If the policy is nil, the default relevant policy will be used.

func (*Client) GrantRoles added in v1.3.0

func (clnt *Client) GrantRoles(policy *AdminPolicy, user string, roles []string) error

Add roles to user's list of roles.

func (*Client) IsConnected

func (clnt *Client) IsConnected() bool

IsConnected determines if the client is ready to talk to the database server cluster.

func (*Client) ListUDF added in v1.0.1

func (clnt *Client) ListUDF(policy *BasePolicy) ([]*UDF, error)

ListUDF lists all packages containing user defined functions in the server. This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) Operate added in v1.0.1

func (clnt *Client) Operate(policy *WritePolicy, key *Key, operations ...*Operation) (*Record, error)

Operate performs multiple read/write operations on a single key in one batch request. An example would be to add an integer value to an existing record and then read the result, all in one database call.

Write operations are always performed first, regardless of operation order relative to read operations. If the policy is nil, the default relevant policy will be used.

func (*Client) Prepend

func (clnt *Client) Prepend(policy *WritePolicy, key *Key, binMap BinMap) error

Prepend prepends bin value's string to existing record bin values. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This call works only for string and []byte values. If the policy is nil, the default relevant policy will be used.

func (*Client) PrependBins

func (clnt *Client) PrependBins(policy *WritePolicy, key *Key, bins ...*Bin) error

PrependBins works the same as Prepend, but avoids BinMap allocation and iteration.

func (*Client) Put

func (clnt *Client) Put(policy *WritePolicy, key *Key, binMap BinMap) error

Put writes record bin(s) to the server. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. If the policy is nil, the default relevant policy will be used.

func (*Client) PutBins

func (clnt *Client) PutBins(policy *WritePolicy, key *Key, bins ...*Bin) error

PutBins writes record bin(s) to the server. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. This method avoids using the BinMap allocation and iteration and is lighter on GC. If the policy is nil, the default relevant policy will be used.

func (*Client) PutObject added in v1.4.0

func (clnt *Client) PutObject(policy *WritePolicy, key *Key, obj interface{}) (err error)

PutObject writes record bin(s) to the server. The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists. If the policy is nil, the default relevant policy will be used.

func (*Client) Query added in v1.0.1

func (clnt *Client) Query(policy *QueryPolicy, statement *Statement) (*Recordset, error)

Query executes a query and returns a Recordset. The query executor puts records on the channel from separate goroutines. The caller can concurrently pop records off the channel through the Recordset.Records channel.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) QueryNode added in v1.3.0

func (clnt *Client) QueryNode(policy *QueryPolicy, node *Node, statement *Statement) (*Recordset, error)

QueryNode executes a query on a specific node and returns a recordset. The caller can concurrently pop records off the channel through the record channel.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) QueryUser added in v1.3.0

func (clnt *Client) QueryUser(policy *AdminPolicy, user string) (*UserRoles, error)

Retrieve roles for a given user.

func (*Client) QueryUsers added in v1.3.0

func (clnt *Client) QueryUsers(policy *AdminPolicy) ([]*UserRoles, error)

Retrieve all users and their roles.

func (*Client) RegisterUDF added in v1.0.1

func (clnt *Client) RegisterUDF(policy *WritePolicy, udfBody []byte, serverPath string, language Language) (*RegisterTask, error)

RegisterUDF registers a package containing user defined functions with server. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RegisterTask instance.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) RegisterUDFFromFile added in v1.0.1

func (clnt *Client) RegisterUDFFromFile(policy *WritePolicy, clientPath string, serverPath string, language Language) (*RegisterTask, error)

RegisterUDFFromFile reads a file from file system and registers the containing a package user defined functions with the server. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RegisterTask instance.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) RemoveUDF added in v1.0.1

func (clnt *Client) RemoveUDF(policy *WritePolicy, udfName string) (*RemoveTask, error)

RemoveUDF removes a package containing user defined functions in the server. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned RemoveTask instance.

This method is only supported by Aerospike 3 servers. If the policy is nil, the default relevant policy will be used.

func (*Client) RevokeRoles added in v1.3.0

func (clnt *Client) RevokeRoles(policy *AdminPolicy, user string, roles []string) error

Remove roles from user's list of roles.

func (*Client) ScanAll added in v1.0.1

func (clnt *Client) ScanAll(apolicy *ScanPolicy, namespace string, setName string, binNames ...string) (*Recordset, error)

ScanAll reads all records in specified namespace and set from all nodes. If the policy's concurrentNodes is specified, each server node will be read in parallel. Otherwise, server nodes are read sequentially. If the policy is nil, the default relevant policy will be used.

func (*Client) ScanNode added in v1.0.1

func (clnt *Client) ScanNode(apolicy *ScanPolicy, node *Node, namespace string, setName string, binNames ...string) (*Recordset, error)

ScanNode reads all records in specified namespace and set for one node only. If the policy is nil, the default relevant policy will be used.

func (*Client) Touch

func (clnt *Client) Touch(policy *WritePolicy, key *Key) error

Touch updates a record's metadata. If the record exists, the record's TTL will be reset to the policy's expiration. If the record doesn't exist, it will return an error.

type ClientPolicy

type ClientPolicy struct {
	// User authentication to cluster. Leave empty for clusters running without restricted access.
	User string

	// Password authentication to cluster. The password will be stored by the client and sent to server
	// in hashed format. Leave empty for clusters running without restricted access.
	Password string

	// Initial host connection timeout in milliseconds.  The timeout when opening a connection
	// to the server host for the first time.
	Timeout time.Duration //= 1 second

	// Connection idle timeout. Every time a connection is used, its idle
	// deadline will be extended by this duration. When this deadline is reached,
	// the connection will be closed and discarded from the connection pool.
	IdleTimeout time.Duration //= 14 seconds

	// Size of the Connection Queue cache.
	ConnectionQueueSize int //= 256

	// If set to true, will not create a new connection
	// to the node if there are already `ConnectionQueueSize` active connections.
	LimitConnectionsToQueueSize bool //= false

	// Throw exception if host connection fails during addHost().
	FailIfNotConnected bool //= true

	// TendInterval determines interval for checking for cluster state changes.
	// Minimum possible interval is 10 Miliseconds.
	TendInterval time.Duration //= 1 second
}

ClientPolicy encapsulates parameters for client policy command.

func NewClientPolicy

func NewClientPolicy() *ClientPolicy

NewClientPolicy generates a new ClientPolicy with default values.

func (*ClientPolicy) RequiresAuthentication added in v1.3.0

func (cp *ClientPolicy) RequiresAuthentication() bool

RequiresAuthentication returns true if a USer or Password is set for ClientPolicy.

type Cluster

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

Cluster encapsulates the aerospike cluster nodes and manages them.

func NewCluster

func NewCluster(policy *ClientPolicy, hosts []*Host) (*Cluster, error)

NewCluster generates a Cluster instance.

func (*Cluster) AddSeeds

func (clstr *Cluster) AddSeeds(hosts []*Host)

AddSeeds adds new hosts to the cluster. They will be added to the cluster on next tend call.

func (*Cluster) ClientPolicy added in v1.5.1

func (clstr *Cluster) ClientPolicy() (res ClientPolicy)

func (*Cluster) Close

func (clstr *Cluster) Close()

Close closes all cached connections to the cluster nodes and stops the tend goroutine.

func (*Cluster) GetNode

func (clstr *Cluster) GetNode(partition *Partition) (*Node, error)

GetNode returns a node for the provided partition.

func (*Cluster) GetNodeByName

func (clstr *Cluster) GetNodeByName(nodeName string) (*Node, error)

GetNodeByName finds a node by name and returns an error if the node is not found.

func (*Cluster) GetNodes

func (clstr *Cluster) GetNodes() []*Node

GetNodes returns a list of all nodes in the cluster

func (*Cluster) GetRandomNode

func (clstr *Cluster) GetRandomNode() (*Node, error)

GetRandomNode returns a random node on the cluster

func (*Cluster) IsConnected

func (clstr *Cluster) IsConnected() bool

IsConnected returns true if cluster has nodes and is not already closed.

func (*Cluster) MigrationInProgress added in v1.0.1

func (clstr *Cluster) MigrationInProgress(timeout time.Duration) (res bool, err error)

MigrationInProgress determines if any node in the cluster is participating in a data migration

func (*Cluster) Password added in v1.5.1

func (clstr *Cluster) Password() (res []byte)

func (*Cluster) WaitUntillMigrationIsFinished added in v1.0.1

func (clstr *Cluster) WaitUntillMigrationIsFinished(timeout time.Duration) (err error)

WaitUntillMigrationIsFinished will block until all migration operations in the cluster all finished.

type CommitLevel added in v1.2.0

type CommitLevel int

Desired consistency guarantee when committing a transaction on the server.

const (
	// Server should wait until successfully committing master and all replicas.
	COMMIT_ALL CommitLevel = iota

	// Server should wait until successfully committing master only.
	COMMIT_MASTER
)

type Connection

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

Connection represents a connection with a timeout.

func NewConnection

func NewConnection(address string, timeout time.Duration) (*Connection, error)

NewConnection creates a connection on the network and returns the pointer A minimum timeout of 2 seconds will always be applied. If the connection is not established in the specified timeout, an error will be returned

func (*Connection) Authenticate added in v1.5.0

func (ctn *Connection) Authenticate(user string, password []byte) error

Authenticate will send authentication information to the server.

func (*Connection) Close

func (ctn *Connection) Close()

Close closes the connection

func (*Connection) IsConnected

func (ctn *Connection) IsConnected() bool

IsConnected returns true if the connection is not closed yet.

func (*Connection) Read

func (ctn *Connection) Read(buf []byte, length int) (total int, err error)

Read reads from connection buffer to the provided slice.

func (*Connection) SetTimeout

func (ctn *Connection) SetTimeout(timeout time.Duration) error

SetTimeout sets connection timeout for both read and write operations.

func (*Connection) Write

func (ctn *Connection) Write(buf []byte) (total int, err error)

Write writes the slice to the connection buffer.

type ConsistencyLevel added in v1.2.0

type ConsistencyLevel int

How replicas should be consulted in a read operation to provide the desired consistency guarantee.

type ExecuteTask added in v1.0.1

type ExecuteTask struct {
	*BaseTask
	// contains filtered or unexported fields
}

ExecuteTask is used to poll for long running server execute job completion.

func NewExecuteTask added in v1.0.1

func NewExecuteTask(cluster *Cluster, statement *Statement) *ExecuteTask

NewExecuteTask initializes task with fields needed to query server nodes.

func (*ExecuteTask) IsDone added in v1.0.1

func (etsk *ExecuteTask) IsDone() (bool, error)

IsDone queries all nodes for task completion status.

func (*ExecuteTask) OnComplete added in v1.0.1

func (etsk *ExecuteTask) OnComplete() chan error

OnComplete returns a channel which will be closed when the task is completed. If an error is encountered while performing the task, an error will be sent on the channel.

type FieldType

type FieldType int

FieldType represents the type of the field in Aerospike Wire Protocol

const (
	NAMESPACE FieldType = 0
	TABLE     FieldType = 1
	KEY       FieldType = 2

	DIGEST_RIPE FieldType = 4

	DIGEST_RIPE_ARRAY FieldType = 6
	TRAN_ID           FieldType = 7 // user supplied transaction id, which is simply passed back
	SCAN_OPTIONS      FieldType = 8
	INDEX_NAME        FieldType = 21
	INDEX_RANGE       FieldType = 22
	INDEX_FILTER      FieldType = 23
	INDEX_LIMIT       FieldType = 24
	INDEX_ORDER_BY    FieldType = 25
	UDF_PACKAGE_NAME  FieldType = 30
	UDF_FUNCTION      FieldType = 31
	UDF_ARGLIST       FieldType = 32
	UDF_OP            FieldType = 33
	QUERY_BINLIST     FieldType = 40
)

type Filter added in v1.0.1

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

Filter specifies a query filter definition.

func NewEqualFilter added in v1.0.1

func NewEqualFilter(binName string, value interface{}) *Filter

NewEqualFilter creates a new equality filter instance for query.

func NewRangeFilter added in v1.0.1

func NewRangeFilter(binName string, begin int64, end int64) *Filter

NewRangeFilter creates a range filter for query. Range arguments must be int64 values. String ranges are not supported.

type GenerationPolicy

type GenerationPolicy int

GenerationPolicy determines how to handle record writes based on record generation.

const (
	// NONE means: Do not use record generation to restrict writes.
	NONE GenerationPolicy = iota

	// EXPECT_GEN_EQUAL means: Update/Delete record if expected generation is equal to server generation. Otherwise, fail.
	EXPECT_GEN_EQUAL

	// EXPECT_GEN_GT means: Update/Delete record if expected generation greater than the server generation. Otherwise, fail.
	// This is useful for restore after backup.
	EXPECT_GEN_GT
)

type Host

type Host struct {

	// Host name or IP address of database server.
	Name string

	// Port of database server.
	Port int
	// contains filtered or unexported fields
}

Host name/port of database server.

func NewHost

func NewHost(name string, port int) *Host

NewHost initializes new host instance.

func (*Host) String

func (h *Host) String() string

Implements stringer interface

type IndexTask added in v1.0.1

type IndexTask struct {
	*BaseTask
	// contains filtered or unexported fields
}

IndexTask is used to poll for long running create index completion.

func NewIndexTask added in v1.0.1

func NewIndexTask(cluster *Cluster, namespace string, indexName string) *IndexTask

NewIndexTask initializes a task with fields needed to query server nodes.

func (*IndexTask) IsDone added in v1.0.1

func (tski *IndexTask) IsDone() (bool, error)

IsDone queries all nodes for task completion status.

func (*IndexTask) OnComplete added in v1.0.1

func (tski *IndexTask) OnComplete() chan error

OnComplete returns a channel that will be closed as soon as the task is finished. If an error is encountered during operation, an error will be sent on the channel.

type IndexType added in v1.0.1

type IndexType string

IndexType the type of the secondary index.

const (
	// NUMERIC specifies an index on numeric values.
	NUMERIC IndexType = "NUMERIC"

	// STRING specifies an index on string values.
	STRING IndexType = "STRING"
)

type IntegerValue

type IntegerValue int

IntegerValue encapsulates an integer value.

func NewIntegerValue

func NewIntegerValue(value int) IntegerValue

NewIntegerValue generates an IntegerValue instance.

func (IntegerValue) GetObject

func (vl IntegerValue) GetObject() interface{}

GetObject returns original value as an interface{}.

func (IntegerValue) GetType

func (vl IntegerValue) GetType() int

GetType returns wire protocol value type.

func (IntegerValue) String

func (vl IntegerValue) String() string

String implements Stringer interface.

type Key

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

Key is the unique record identifier. Records can be identified using a specified namespace, an optional set name, and a user defined key which must be unique within a set. Records can also be identified by namespace/digest which is the combination used on the server.

func NewKey

func NewKey(namespace string, setName string, key interface{}) (newKey *Key, err error)

NewKey initializes a key from namespace, optional set name and user key. The set name and user defined key are converted to a digest before sending to the server. The server handles record identifiers by digest only.

func NewKeyWithDigest added in v1.2.0

func NewKeyWithDigest(namespace string, setName string, key interface{}, digest []byte) (newKey *Key, err error)

NewKey initializes a key from namespace, optional set name and user key. The server handles record identifiers by digest only.

func (*Key) Digest

func (ky *Key) Digest() []byte

Digest returns key digest.

func (*Key) Equals

func (ky *Key) Equals(other *Key) bool

Equals uses key digests to compare key equality.

func (*Key) Namespace

func (ky *Key) Namespace() string

Namespace returns key's namespace.

func (*Key) SetDigest added in v1.2.0

func (ky *Key) SetDigest(digest []byte) error

Set custom hash

func (*Key) SetName

func (ky *Key) SetName() string

SetName returns key's set name.

func (*Key) String added in v1.0.1

func (ky *Key) String() string

String implements Stringer interface and returns string representation of key.

func (*Key) Value added in v1.0.1

func (ky *Key) Value() Value

Value returns key's value.

type Language added in v1.0.1

type Language string

Language specifies User defined function languages.

const (

	// LUA embedded programming language.
	LUA Language = "LUA"
)

type LargeList added in v1.0.1

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

LargeList encapsulates a list within a single bin.

func NewLargeList added in v1.0.1

func NewLargeList(client *Client, policy *WritePolicy, key *Key, binName string, userModule string) *LargeList

NewLargeList initializes a large list operator.

func (*LargeList) Add added in v1.0.1

func (ll *LargeList) Add(values ...interface{}) (err error)

Add adds values to the list. If the list does not exist, create it

func (*LargeList) Destroy added in v1.0.1

func (ll *LargeList) Destroy() error

Destroy deletes the bin containing the list.

func (*LargeList) FFilterThenindFirst added in v1.6.0

func (ll *LargeList) FFilterThenindFirst(count int, filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error)

Select values from the beginning of list up to a maximum count after applying lua filter.

func (*LargeList) Filter added in v1.0.1

func (ll *LargeList) Filter(filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error)

Filter selects values from list and apply specified Lua filter.

func (*LargeList) FilterThenFindFrom added in v1.6.0

func (ll *LargeList) FilterThenFindFrom(begin interface{}, count int, filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error)

Select values from the begin key up to a maximum count after applying lua filter.

func (*LargeList) FilterThenFindLast added in v1.6.0

func (ll *LargeList) FilterThenFindLast(count int, filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error)

Select values from the end of list up to a maximum count after applying lua filter.

func (*LargeList) Find added in v1.0.1

func (ll *LargeList) Find(value interface{}) ([]interface{}, error)

Find selects values from list.

func (*LargeList) FindFirst added in v1.6.0

func (ll *LargeList) FindFirst(count int) ([]interface{}, error)

Select values from the beginning of list up to a maximum count.

func (*LargeList) FindFrom added in v1.6.0

func (ll *LargeList) FindFrom(begin interface{}, count int) ([]interface{}, error)

Select values from the begin key up to a maximum count.

func (*LargeList) FindLast added in v1.6.0

func (ll *LargeList) FindLast(count int) ([]interface{}, error)

Select values from the end of list up to a maximum count.

func (*LargeList) FindThenFilter added in v1.0.1

func (ll *LargeList) FindThenFilter(value interface{}, filterModule, filterName string, filterArgs ...interface{}) ([]interface{}, error)

FindThenFilter selects values from list and applies specified Lua filter.

func (*LargeList) GetConfig added in v1.0.1

func (ll *LargeList) GetConfig() (map[interface{}]interface{}, error)

GetConfig returns map of list configuration parameters.

func (*LargeList) Range added in v1.2.0

func (ll *LargeList) Range(begin, end interface{}) ([]interface{}, error)

Select a range of values from the large list.

func (*LargeList) RangeN added in v1.6.0

func (ll *LargeList) RangeN(begin, end interface{}, count int) ([]interface{}, error)

Select a range of values up to a maximum count from the large list.

func (*LargeList) RangeNThenFilter added in v1.6.0

func (ll *LargeList) RangeNThenFilter(begin, end interface{}, count int, filterModule string, filterName string, filterArgs ...interface{}) ([]interface{}, error)

Select a range of values up to a maximum count from the large list then apply filter.

func (*LargeList) RangeThenFilter added in v1.2.0

func (ll *LargeList) RangeThenFilter(begin, end interface{}, filterModule string, filterName string, filterArgs ...interface{}) ([]interface{}, error)

Select a range of values from the large list then apply filter.

func (*LargeList) Remove added in v1.0.1

func (ll *LargeList) Remove(values ...interface{}) (err error)

Remove deletes value from list.

func (*LargeList) Scan added in v1.0.1

func (ll *LargeList) Scan() ([]interface{}, error)

Scan returns all objects in the list.

func (*LargeList) SetPageSize added in v1.6.0

func (ll *LargeList) SetPageSize(pageSize int) error

Set LDT page size.

func (*LargeList) Size added in v1.0.1

func (ll *LargeList) Size() (int, error)

Size returns size of list.

func (*LargeList) Update added in v1.0.2

func (ll *LargeList) Update(values ...interface{}) (err error)

Update updates/adds each value in values list depending if key exists or not.

type LargeMap added in v1.0.1

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

LargeMap encapsulates a map within a single bin.

func NewLargeMap added in v1.0.1

func NewLargeMap(client *Client, policy *WritePolicy, key *Key, binName string, userModule string) *LargeMap

NewLargeMap initializes a large map operator.

func (*LargeMap) Destroy added in v1.0.1

func (lm *LargeMap) Destroy() error

Destroy deletes the bin containing the map.

func (*LargeMap) Exists added in v1.2.0

func (lm *LargeMap) Exists(keyValue interface{}) (bool, error)

Check existence of key in the map.

func (*LargeMap) Filter added in v1.0.1

func (lm *LargeMap) Filter(filterName string, filterArgs ...interface{}) (map[interface{}]interface{}, error)

Filter selects items from the map.

func (*LargeMap) Get added in v1.0.1

func (lm *LargeMap) Get(name interface{}) (map[interface{}]interface{}, error)

Get returns value from map corresponding with the provided key.

func (*LargeMap) GetConfig added in v1.0.1

func (lm *LargeMap) GetConfig() (map[interface{}]interface{}, error)

GetConfig returns map of map configuration parameters.

func (*LargeMap) Put added in v1.0.1

func (lm *LargeMap) Put(name interface{}, value interface{}) error

Put adds an entry to the map. If the map does not exist, create it using specified userModule configuration.

func (*LargeMap) PutMap added in v1.0.1

func (lm *LargeMap) PutMap(theMap map[interface{}]interface{}) error

PutMap adds map values to the map. If the map does not exist, create it using specified userModule configuration.

func (*LargeMap) Remove added in v1.0.2

func (lm *LargeMap) Remove(name interface{}) error

Remove deletes a value from map given a key.

func (*LargeMap) Scan added in v1.0.1

func (lm *LargeMap) Scan() (map[interface{}]interface{}, error)

Scan returns all objects in the map.

func (*LargeMap) Size added in v1.0.1

func (lm *LargeMap) Size() (int, error)

Size returns size of the map.

type LargeObject added in v1.0.1

type LargeObject interface {
	// Destroy the bin containing LDT.
	Destroy() error
	// Size returns the size of the LDT.
	Size() (int, error)
	// GetConfig returns a map containing LDT config values.
	GetConfig() (map[interface{}]interface{}, error)
}

LargeObject interface defines methods to work with LDTs.

type LargeSet added in v1.0.1

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

LargeSet encapsulates a set within a single bin.

func NewLargeSet added in v1.0.1

func NewLargeSet(client *Client, policy *WritePolicy, key *Key, binName string, userModule string) *LargeSet

NewLargeSet initializes a large set operator.

func (*LargeSet) Add added in v1.0.1

func (ls *LargeSet) Add(values ...interface{}) error

Add adds values to the set. If the set does not exist, create it using specified userModule configuration.

func (*LargeSet) Destroy added in v1.0.1

func (ls *LargeSet) Destroy() error

Destroy deletes the bin containing the set.

func (*LargeSet) Exists added in v1.0.1

func (ls *LargeSet) Exists(value interface{}) (bool, error)

Exists checks existence of value in the set.

func (*LargeSet) Filter added in v1.0.1

func (ls *LargeSet) Filter(filterName string, filterArgs ...interface{}) ([]interface{}, error)

Filter select values from set and applies specified Lua filter.

func (*LargeSet) Get added in v1.0.1

func (ls *LargeSet) Get(value interface{}) (interface{}, error)

Get selects a value from set.

func (*LargeSet) GetConfig added in v1.0.1

func (ls *LargeSet) GetConfig() (map[interface{}]interface{}, error)

GetConfig returns map of set configuration parameters.

func (*LargeSet) Remove added in v1.0.1

func (ls *LargeSet) Remove(value interface{}) error

Remove delete value from set.

func (*LargeSet) Scan added in v1.0.1

func (ls *LargeSet) Scan() ([]interface{}, error)

Scan returns all objects in the set.

func (*LargeSet) Size added in v1.0.1

func (ls *LargeSet) Size() (int, error)

Size returns size of the set.

type LargeStack added in v1.0.1

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

LargeStack encapsulates a stack within a single bin. A stack is last in/first out (LIFO) data structure.

func NewLargeStack added in v1.0.1

func NewLargeStack(client *Client, policy *WritePolicy, key *Key, binName string, userModule string) *LargeStack

NewLargeStack initializes a large stack operator.

func (*LargeStack) Destroy added in v1.0.1

func (lstk *LargeStack) Destroy() error

Destroy deletes the bin containing the stack.

func (*LargeStack) Filter added in v1.0.1

func (lstk *LargeStack) Filter(peekCount int, filterName string, filterArgs ...interface{}) ([]interface{}, error)

Filter selects items from top of stack.

func (*LargeStack) GetConfig added in v1.0.1

func (lstk *LargeStack) GetConfig() (map[interface{}]interface{}, error)

GetConfig returns map of stack configuration parameters.

func (*LargeStack) Peek added in v1.0.1

func (lstk *LargeStack) Peek(peekCount int) ([]interface{}, error)

Peek select items from top of stack, without removing them

func (*LargeStack) Pop added in v1.0.1

func (lstk *LargeStack) Pop(count int) ([]interface{}, error)

Pop selects items from top of stack and then removes them.

func (*LargeStack) Push added in v1.0.1

func (lstk *LargeStack) Push(values ...interface{}) error

Push pushes values onto stack. If the stack does not exist, create it using specified userModule configuration.

func (*LargeStack) Scan added in v1.0.1

func (lstk *LargeStack) Scan() ([]interface{}, error)

Scan returns all objects in the stack.

func (*LargeStack) Size added in v1.0.1

func (lstk *LargeStack) Size() (int, error)

Size returns size of the stack.

type ListValue

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

ListValue encapsulates any arbitray array. Supported by Aerospike 3 servers only.

func NewListValue

func NewListValue(list []interface{}) *ListValue

NewListValue generates a ListValue instance.

func (*ListValue) GetObject

func (vl *ListValue) GetObject() interface{}

GetObject returns original value as an interface{}.

func (*ListValue) GetType

func (vl *ListValue) GetType() int

GetType returns wire protocol value type.

func (*ListValue) String

func (vl *ListValue) String() string

String implements Stringer interface.

type LongValue

type LongValue int64

LongValue encapsulates an int64 value.

func NewLongValue

func NewLongValue(value int64) LongValue

NewLongValue generates a LongValue instance.

func (LongValue) GetObject

func (vl LongValue) GetObject() interface{}

GetObject returns original value as an interface{}.

func (LongValue) GetType

func (vl LongValue) GetType() int

GetType returns wire protocol value type.

func (LongValue) String

func (vl LongValue) String() string

String implements Stringer interface.

type MapValue

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

MapValue encapsulates an arbitray map. Supported by Aerospike 3 servers only.

func NewMapValue

func NewMapValue(vmap map[interface{}]interface{}) *MapValue

NewMapValue generates a MapValue instance.

func (*MapValue) GetObject

func (vl *MapValue) GetObject() interface{}

GetObject returns original value as an interface{}.

func (*MapValue) GetType

func (vl *MapValue) GetType() int

GetType returns wire protocol value type.

func (*MapValue) String

func (vl *MapValue) String() string

String implements Stringer interface.

type MultiPolicy added in v1.0.2

type MultiPolicy struct {
	*BasePolicy

	// Maximum number of concurrent requests to server nodes at any poin int time.
	// If there are 16 nodes in the cluster and maxConcurrentNodes is 8, then queries
	// will be made to 8 nodes in parallel.  When a query completes, a new query will
	// be issued until all 16 nodes have been queried.
	// Default (0) is to issue requests to all server nodes in parallel.
	MaxConcurrentNodes int

	// Number of records to place in queue before blocking.
	// Records received from multiple server nodes will be placed in a queue.
	// A separate goroutine consumes these records in parallel.
	// If the queue is full, the producer goroutines will block until records are consumed.
	RecordQueueSize int //= 5000

	// Blocks until on-going migrations are over
	WaitUntilMigrationsAreOver bool //=false
}

MultiPolicy contains parameters for policy attributes used in query and scan operations.

func NewMultiPolicy added in v1.0.2

func NewMultiPolicy() *MultiPolicy

NewMultiPolicy initializes a MultiPolicy instance with default values.

type Node

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

Node represents an Aerospike Database Server Node

func (*Node) AddAlias

func (nd *Node) AddAlias(aliasToAdd *Host)

AddAlias adds an alias for the node

func (*Node) Close

func (nd *Node) Close()

Close marks node as inactice and closes all of its pooled connections.

func (*Node) DecreaseHealth

func (nd *Node) DecreaseHealth()

DecreaseHealth decreases node Health as a result of bad connection or communication.

func (*Node) Equals

func (nd *Node) Equals(other *Node) bool

Equals compares equality of two nodes based on their names.

func (*Node) GetAliases

func (nd *Node) GetAliases() []*Host

GetAliases returnss node aliases.

func (*Node) GetConnection

func (nd *Node) GetConnection(timeout time.Duration) (conn *Connection, err error)

GetConnection gets a connection to the node. If no pooled connection is available, a new connection will be created.

func (*Node) GetHost

func (nd *Node) GetHost() *Host

GetHost retrieves host for the node.

func (*Node) GetName

func (nd *Node) GetName() string

GetName returns node name.

func (*Node) InvalidateConnection added in v1.6.0

func (nd *Node) InvalidateConnection(conn *Connection)

InvalidateConnection closes and discards a connection from the pool.

func (*Node) IsActive

func (nd *Node) IsActive() bool

IsActive Checks if the node is active.

func (*Node) IsUnhealthy

func (nd *Node) IsUnhealthy() bool

IsUnhealthy checks if the node is unhealthy.

func (*Node) MigrationInProgress added in v1.0.1

func (nd *Node) MigrationInProgress() (bool, error)

MigrationInProgress determines if the node is participating in a data migration

func (*Node) PutConnection

func (nd *Node) PutConnection(conn *Connection)

PutConnection puts back a connection to the pool. If connection pool is full, the connection will be closed and discarded.

func (*Node) Refresh

func (nd *Node) Refresh() ([]*Host, error)

Refresh requests current status from server node, and updates node with the result.

func (*Node) RestoreHealth

func (nd *Node) RestoreHealth()

RestoreHealth marks the node as healthy.

func (*Node) String

func (nd *Node) String() string

String implements stringer interface

func (*Node) WaitUntillMigrationIsFinished added in v1.0.1

func (nd *Node) WaitUntillMigrationIsFinished(timeout time.Duration) (err error)

WaitUntillMigrationIsFinished will block until migration operations are finished.

type NodeError added in v1.0.1

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

NodeError is a type to encapsulate the node that the error occured in.

func (*NodeError) Node added in v1.0.1

func (ne *NodeError) Node() *Node

Node returns the node where the error occured.

type NullValue

type NullValue struct{}

NullValue is an empty value.

func NewNullValue added in v1.0.1

func NewNullValue() NullValue

NewNullValue generates a NullValue instance.

func (NullValue) GetObject

func (vl NullValue) GetObject() interface{}

GetObject returns original value as an interface{}.

func (NullValue) GetType

func (vl NullValue) GetType() int

GetType returns wire protocol value type.

func (NullValue) String

func (vl NullValue) String() string

String implements Stringer interface.

type Operation

type Operation struct {

	// OpType determines type of operation.
	OpType OperationType

	// BinName (Optional) determines the name of bin used in operation.
	BinName string

	// BinValue (Optional) determines bin value used in operation.
	BinValue Value
	// contains filtered or unexported fields
}

Operation contasins operation definition. This struct is used in client's operate() method.

func AddOp added in v1.0.1

func AddOp(bin *Bin) *Operation

AddOp creates integer add database operation.

func AppendOp added in v1.0.1

func AppendOp(bin *Bin) *Operation

AppendOp creates string append database operation.

func GetHeaderOp added in v1.0.1

func GetHeaderOp() *Operation

GetHeaderOp creates read record header database operation.

func GetOp added in v1.0.1

func GetOp() *Operation

GetOp creates read all record bins database operation.

func GetOpForBin added in v1.0.1

func GetOpForBin(binName string) *Operation

GetOpForBin creates read bin database operation.

func PrependOp added in v1.0.1

func PrependOp(bin *Bin) *Operation

PrependOp creates string prepend database operation.

func PutOp added in v1.0.1

func PutOp(bin *Bin) *Operation

PutOp creates set database operation.

func TouchOp added in v1.0.1

func TouchOp() *Operation

TouchOp creates touch database operation.

type OperationType

type OperationType byte

OperationType determines operation type

const (
	READ OperationType = 1
	// READ_HEADER OperationType = 1
	WRITE   OperationType = 2
	ADD     OperationType = 5
	APPEND  OperationType = 9
	PREPEND OperationType = 10
	TOUCH   OperationType = 11
)

type Partition

type Partition struct {
	Namespace   string
	PartitionId int
}

Partition encapsulates partition information.

func NewPartition

func NewPartition(namespace string, partitionId int) *Partition

NewPartition generates a partition instance.

func NewPartitionByKey

func NewPartitionByKey(key *Key) *Partition

NewPartitionByKey initializes a partition and determines the Partition Id from key digest automatically.

func (*Partition) Equals

func (ptn *Partition) Equals(other *Partition) bool

Equals checks equality of two partitions.

func (*Partition) String

func (ptn *Partition) String() string

String implements the Stringer interface.

type Policy

type Policy interface {
	// Retrives BasePolicy
	GetBasePolicy() *BasePolicy
}

Policy Interface

type Priority

type Priority int

Priority of operations on database server.

const (

	// DEFAULT determines that the server defines the priority.
	DEFAULT Priority = iota

	// LOW determines that the server should run the operation in a background thread.
	LOW

	// MEDIUM determines that the server should run the operation at medium priority.
	MEDIUM

	// HIGH determines that the server should run the operation at the highest priority.
	HIGH
)

type QueryPolicy

type QueryPolicy struct {
	*MultiPolicy
}

QueryPolicy encapsulates parameters for policy attributes used in query operations.

func NewQueryPolicy added in v1.0.1

func NewQueryPolicy() *QueryPolicy

NewQueryPolicy generates a new QueryPolicy instance with default values.

type Record

type Record struct {
	// Key is the record's key.
	// Might be empty, or may only consist of digest value.
	Key *Key

	// Node from which the Record is originating from.
	Node *Node

	// Bins is the map of requested name/value bins.
	Bins BinMap

	// Generation shows record modification count.
	Generation int

	// Expiration is TTL (Time-To-Live).
	// Number of seconds until record expires.
	Expiration int
}

Record is the container struct for database records. Records are equivalent to rows.

func (*Record) String

func (rc *Record) String() string

String implements the Stringer interface. Returns string representation of record.

type RecordExistsAction

type RecordExistsAction int

RecordExistsAction determines how to handle writes when the record already exists.

const (

	// UPDATE means: Create or update record.
	// Merge write command bins with existing bins.
	UPDATE RecordExistsAction = iota

	// UPDATE_ONLY means: Update record only. Fail if record does not exist.
	// Merge write command bins with existing bins.
	UPDATE_ONLY

	// REPLACE means: Create or replace record.
	// Delete existing bins not referenced by write command bins.
	// Supported by Aerospike 2 server versions >= 2.7.5 and
	// Aerospike 3 server versions >= 3.1.6.
	REPLACE

	// REPLACE_ONLY means: Replace record only. Fail if record does not exist.
	// Delete existing bins not referenced by write command bins.
	// Supported by Aerospike 2 server versions >= 2.7.5 and
	// Aerospike 3 server versions >= 3.1.6.
	REPLACE_ONLY

	// CREATE_ONLY means: Create only. Fail if record exists.
	CREATE_ONLY
)

type Recordset added in v1.0.1

type Recordset struct {
	// Records is a channel on which the resulting records will be sent back.
	// NOTE: Do not use Records directly. Range on channel returned by Results() instead.
	// Will be unexported in the future
	Records chan *Record
	// Errors is a channel on which all errors will be sent back.
	// NOTE: Do not use Records directly. Range on channel returned by Results() instead.
	// Will be unexported in the future
	Errors chan error
	// contains filtered or unexported fields
}

Recordset encapsulates the result of Scan and Query commands.

func (*Recordset) Close added in v1.0.1

func (rcs *Recordset) Close()

Close all streams from different nodes.

func (*Recordset) IsActive added in v1.0.1

func (rcs *Recordset) IsActive() bool

IsActive returns true if the operation hasn't been finished or cancelled.

func (*Recordset) Results added in v1.4.0

func (rcs *Recordset) Results() <-chan *Result

Results returns a new receive-only channel with the results of the Scan/Query This is a more idiomatic approach to the iterator pattern in getting the results back from the recordset, and doesn't require the user to write the ugly select in their code. Result embeds A Record and an error reference.

Example:

recordset, err := client.ScanAll(nil, namespace, set) handleError(err)

for res := range recordset.Results() {
  if res.Err != nil {
    // handle error here
  } else {
    // process record here
    fmt.Println(res.Record.Bins)
  }
}

type RegisterTask added in v1.0.1

type RegisterTask struct {
	*BaseTask
	// contains filtered or unexported fields
}

RegisterTask is used to poll for UDF registration completion.

func NewRegisterTask added in v1.0.1

func NewRegisterTask(cluster *Cluster, packageName string) *RegisterTask

NewRegisterTask initializes a RegisterTask with fields needed to query server nodes.

func (*RegisterTask) IsDone added in v1.0.1

func (tskr *RegisterTask) IsDone() (bool, error)

IsDone will query all nodes for task completion status.

func (*RegisterTask) OnComplete added in v1.0.1

func (tskr *RegisterTask) OnComplete() chan error

OnComplete returns a channel that will be closed as soon as the task is finished. If an error is encountered during operation, an error will be sent on the channel.

type RemoveTask added in v1.0.1

type RemoveTask struct {
	*BaseTask
	// contains filtered or unexported fields
}

RemoveTask is used to poll for UDF registration completion.

func NewRemoveTask added in v1.0.1

func NewRemoveTask(cluster *Cluster, packageName string) *RemoveTask

NewRemoveTask initializes a RemoveTask with fields needed to query server nodes.

func (*RemoveTask) IsDone added in v1.0.1

func (tskr *RemoveTask) IsDone() (bool, error)

IsDone will query all nodes for task completion status.

func (*RemoveTask) OnComplete added in v1.0.1

func (tskr *RemoveTask) OnComplete() chan error

OnComplete returns a channel that will be closed as soon as the task is finished. If an error is encountered during operation, an error will be sent on the channel.

type Result added in v1.6.0

type Result struct {
	Record *Record
	Err    error
}

type Role added in v1.3.0

type Role string
const (
	// Manage users their roles.
	UserAdmin Role = "user-admin"

	// Manage indicies, user defined functions and server configuration.
	SysAdmin Role = "sys-admin"

	// Allow read and write transactions with the database.
	ReadWrite Role = "read-write"

	// Allow read transactions with the database.
	Read Role = "Read"
)

Pre-defined user roles.

type ScanPolicy

type ScanPolicy struct {
	*MultiPolicy

	// ScanPercent determines percent of data to scan.
	// Valid integer range is 1 to 100.
	// Default is 100.
	ScanPercent int //= 100;

	// ConcurrentNodes determines how to issue scan requests (in parallel or sequentially).
	ConcurrentNodes bool //= true;

	// Indicates if bin data is retrieved. If false, only record digests are retrieved.
	IncludeBinData bool //= true;

	// FailOnClusterChange determines scan termination if cluster is in fluctuating state.
	FailOnClusterChange bool
}

ScanPolicy encapsulates parameters used in scan operations.

func NewScanPolicy added in v1.0.1

func NewScanPolicy() *ScanPolicy

NewScanPolicy creates a new ScanPolicy instance with default values.

type Statement added in v1.0.1

type Statement struct {
	// Namespace determines query Namespace
	Namespace string

	// SetName determines query Set name (Optional)
	SetName string

	// IndexName determines query index name (Optional)
	// If not set, the server will determine the index from the filter's bin name.
	IndexName string

	// BinNames detemines bin names (optional)
	BinNames []string

	// Filters determine query filters (Optional)
	// Currently, only one filter is allowed by the server on a secondary index lookup.
	// If multiple filters are necessary, see QueryFilter example for a workaround.
	// QueryFilter demonstrates how to add additional filters in an user-defined
	// aggregation function.
	Filters []*Filter

	// TaskId determines query task id. (Optional)
	TaskId int64
	// contains filtered or unexported fields
}

Statement encapsulates query statement parameters.

func NewStatement added in v1.0.1

func NewStatement(ns string, set string, binNames ...string) *Statement

NewStatement initializes a new Statement instance.

func (*Statement) Addfilter added in v1.0.1

func (stmt *Statement) Addfilter(filter *Filter) error

Addfilter adds a filter to the statement.

func (*Statement) IsScan added in v1.0.1

func (stmt *Statement) IsScan() bool

IsScan determines is the Statement is a full namespace/set scan or a selective Query.

func (*Statement) SetAggregateFunction added in v1.0.1

func (stmt *Statement) SetAggregateFunction(packageName string, functionName string, functionArgs []Value, returnData bool)

SetAggregateFunction sets aggregation function parameters. This function will be called on both the server and client for each selected item.

type StringValue

type StringValue string

StringValue encapsulates a string value.

func NewStringValue

func NewStringValue(value string) StringValue

NewStringValue generates a StringValue instance.

func (StringValue) GetObject

func (vl StringValue) GetObject() interface{}

GetObject returns original value as an interface{}.

func (StringValue) GetType

func (vl StringValue) GetType() int

GetType returns wire protocol value type.

func (StringValue) String

func (vl StringValue) String() string

String implements Stringer interface.

type SyncMap added in v1.4.0

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

type Task added in v1.0.1

type Task interface {
	IsDone() (bool, error)

	OnComplete() chan error
	// contains filtered or unexported methods
}

Task interface defines methods for asynchronous tasks.

type UDF added in v1.0.1

type UDF struct {
	// Filename of the UDF
	Filename string
	// Hash digest of the UDF
	Hash string
	// Language of UDF
	Language Language
}

UDF carries information about UDFs on the server

type UserRoles added in v1.3.0

type UserRoles struct {
	// User name.
	User string

	// List of assigned roles.
	Roles []string
}

User and assigned roles.

type Value

type Value interface {

	// GetType returns wire protocol value type.
	GetType() int

	// GetObject returns original value as an interface{}.
	GetObject() interface{}

	// String implements Stringer interface.
	String() string
	// contains filtered or unexported methods
}

Value interface is used to efficiently serialize objects into the wire protocol.

func NewValue

func NewValue(v interface{}) Value

NewValue generates a new Value object based on the type. If the type is not supported, NewValue will panic.

type ValueArray

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

ValueArray encapsulates an array of Value. Supported by Aerospike 3 servers only.

func NewValueArray

func NewValueArray(array []Value) *ValueArray

NewValueArray generates a ValueArray instance.

func ToValueArray added in v1.0.1

func ToValueArray(array []interface{}) *ValueArray

ToValueArray converts a []interface{} to []Value. It will panic if any of array element types are not supported.

func (*ValueArray) GetObject

func (vl *ValueArray) GetObject() interface{}

GetObject returns original value as an interface{}.

func (*ValueArray) GetType

func (vl *ValueArray) GetType() int

GetType returns wire protocol value type.

func (*ValueArray) String

func (vl *ValueArray) String() string

String implements Stringer interface.

type WritePolicy

type WritePolicy struct {
	BasePolicy

	// RecordExistsAction qualifies how to handle writes where the record already exists.
	RecordExistsAction RecordExistsAction //= RecordExistsAction.UPDATE;

	// GenerationPolicy qualifies how to handle record writes based on record generation. The default (NONE)
	// indicates that the generation is not used to restrict writes.
	GenerationPolicy GenerationPolicy //= GenerationPolicy.NONE;

	// Desired consistency guarantee when committing a transaction on the server. The default
	// (COMMIT_ALL) indicates that the server should wait for master and all replica commits to
	// be successful before returning success to the client.
	CommitLevel CommitLevel //= COMMIT_ALL

	// Generation determines expected generation.
	// Generation is the number of times a record has been
	// modified (including creation) on the server.
	// If a write operation is creating a record, the expected generation would be 0.
	Generation int32

	// Expiration determimes record expiration in seconds. Also known as TTL (Time-To-Live).
	// Seconds record will live before being removed by the server.
	// Expiration values:
	// -1: Never expire for Aerospike 2 server versions >= 2.7.2 and Aerospike 3 server
	// versions >= 3.1.4.  Do not use -1 for older servers.
	// 0: Default to namespace configuration variable "default-ttl" on the server.
	// > 0: Actual expiration in seconds.
	Expiration int32

	// Send user defined key in addition to hash digest on a record put.
	// The default is to not send the user defined key.
	SendKey bool
}

WritePolicy encapsulates parameters for policy attributes used in write operations. This object is passed into methods where database writes can occur.

func NewWritePolicy

func NewWritePolicy(generation, expiration int32) *WritePolicy

NewWritePolicy initializes a new WritePolicy instance with default parameters.

Directories

Path Synopsis
* Copyright 2012-2014 Aerospike, Inc.
* Copyright 2012-2014 Aerospike, Inc.
get
put
pkg
ripemd160
Package ripemd160 implements the RIPEMD-160 hash algorithm.
Package ripemd160 implements the RIPEMD-160 hash algorithm.
tools
cli

Jump to

Keyboard shortcuts

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