aerospike

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2014 License: Apache-2.0 Imports: 23 Imported by: 0

README

Aerospike Go Client (BETA1)

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)

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
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

This section is empty.

Variables

This section is empty.

Functions

func RequestInfo

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

Get info values by name from the specified connection

func RequestNodeInfo

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

Get info values by name from the specified database server node.

func RequestNodeStats

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

RequestNodeStats returns statistics for the specified node as a map

func SetCommandBufferPool

func SetCommandBufferPool(poolSize, initBufSize, maxBufferSize int)

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

Types

type AerospikeBlob

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

type BasePolicy

type BasePolicy struct {
	Policy

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

	// 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

	// 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;

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

Container object for transaction policy attributes used in all database operation calls.

func NewPolicy

func NewPolicy() *BasePolicy

func (*BasePolicy) GetBasePolicy

func (p *BasePolicy) GetBasePolicy() *BasePolicy

type BaseTask

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

Task used to poll for server task completion.

func NewTask

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

Initialize 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
}

Column name/value pair.

func NewBin

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

Constructor, specifying bin name and string value. For servers configured as "single-bin", enter an empty name.

func (*Bin) String

func (bn *Bin) String() string

Implements Stringer interface. string representation of bin.

type BinMap

type BinMap map[string]interface{}

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

type BytesValue

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

Byte array value.

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

func (*BytesValue) GetObject

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

func (*BytesValue) GetType

func (vl *BytesValue) GetType() int

func (*BytesValue) String

func (vl *BytesValue) String() string

type Client

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

func NewClient

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

NewClient generates a new Client

func NewClientWithPolicy

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

NewClientWithPolicy generates a new Client and sets the ClientPolicy

func NewClientWithPolicyAndHost

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

NewClientWithPolicyAndHost generates a new Client and sets the ClientPolicy and sets up the cluster

func (*Client) Add

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

Add 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.

func (*Client) AddBins

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

func (*Client) Append

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

Append bin values 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 values.

func (*Client) AppendBins

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

func (*Client) BatchExists

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

Check if multiple record keys exist in one batch call. The returned array bool is in positional order with the original key array order. The policy can be used to specify timeouts.

func (*Client) BatchGet

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

Read multiple record headers and bins for specified keys in one batch call. 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.

func (*Client) BatchGetHeader

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

Read multiple record header data for specified keys in one batch call. 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.

func (*Client) Close

func (clnt *Client) Close()

Close all client connections to database server nodes.

func (*Client) CreateIndex

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

Create secondary index. This asynchronous server call will return before command is complete. The user can optionally wait for command completion by using the returned IndexTask instance. <p> This method is only supported by Aerospike 3 servers.

func (*Client) Delete

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

Delete record for specified key. The policy specifies the transaction timeout.

func (*Client) DropIndex

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

Delete secondary index. This method is only supported by Aerospike 3 servers.

func (*Client) Execute

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

Execute 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.

func (*Client) ExecuteUDF

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

Apply 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.

func (*Client) Exists

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

Determine if a record key exists. The policy can be used to specify timeouts.

func (*Client) Get

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

Read record header and bins for specified key. The policy can be used to specify timeouts.

func (*Client) GetHeader

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

Read record generation and expiration only for specified key. Bins are not read. The policy can be used to specify timeouts.

func (*Client) GetLargeList

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

Initialize 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.

func (*Client) GetLargeMap

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

Initialize 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.

func (*Client) GetLargeSet

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

Initialize 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.

func (*Client) GetLargeStack

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

Initialize 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.

func (*Client) GetNodeNames

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

Return list of active server node names in the cluster.

func (*Client) GetNodes

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

Return array of active server nodes in the cluster.

func (*Client) IsConnected

func (clnt *Client) IsConnected() bool

Determine if we are ready to talk to the database server cluster.

func (*Client) ListUDF

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.

func (*Client) Operate

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

Perform multiple read/write operations on a single key in one batch call. 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.

func (*Client) Prepend

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

Prepend bin values 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 values.

func (*Client) PrependBins

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

func (*Client) Put

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

Write record bin(s). The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.

func (*Client) PutBins

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

Write record bin(s). The policy specifies the transaction timeout, record expiration and how the transaction is handled when the record already exists.

func (*Client) Query

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

Execute query and return record iterator. The query executor puts records on a channel separate goroutines. The caller concurrently pops records off the channel through the record iterator.

This method is only supported by Aerospike 3 servers.

func (*Client) RegisterUDF

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

Register 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.

func (*Client) RegisterUDFFromFile

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

Register 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.

func (*Client) RemoveUDF

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.

func (*Client) ScanAll

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

Read all records in specified namespace and set. If the policy's concurrentNodes is specified, each server node will be read in parallel. Otherwise, server nodes are read in series.

This call will block until the scan is complete - callbacks are made within the scope of this call.

func (*Client) ScanNode

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

Read all records in specified namespace and set for one node only. The node is specified by name.

This call will block until the scan is complete - callbacks are made within the scope of this call.

func (*Client) Touch

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

Create record if it does not already exist. If the record exists, the record's time to expiration will be reset to the policy's expiration.

type ClientPolicy

type ClientPolicy struct {
	// 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

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

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

Container object for client policy command.

func NewClientPolicy

func NewClientPolicy() *ClientPolicy

Generates a new ClientPolicy with default values

type Cluster

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

func NewCluster

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

func (*Cluster) AddSeeds

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

Adds new hosts to the cluster They will be added to the cluster on next tend

func (*Cluster) Close

func (clstr *Cluster) Close()

Closes all cached connections to the cluster nodes and stops the tend goroutine

func (*Cluster) FindNodeName

func (clstr *Cluster) FindNodeName(list []*Node, name string) bool

FIXIT: This function is not well desined while it is expoted. Finds a node by name in a list of nodes

func (*Cluster) GetNode

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

func (*Cluster) GetNodeByName

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

Find a node by name and returns an error if not found

func (*Cluster) GetNodes

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

Returns a list of all nodes in the cluster

func (*Cluster) GetRandomNode

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

Returns a random node on the cluster

func (*Cluster) IsConnected

func (clstr *Cluster) IsConnected() bool

func (*Cluster) MigrationInProgress

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) WaitUntillMigrationIsFinished

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

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) Close

func (ctn *Connection) Close()

Closes the connection

func (*Connection) IsConnected

func (ctn *Connection) IsConnected() bool

Returns true if the connection is not closed

func (*Connection) Read

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

Reads from connection buffer to the slice

func (*Connection) SetTimeout

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

sets connection timeout

func (*Connection) Write

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

Writes the slice to the connection buffer.

type ExecuteTask

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

Task used to poll for long running server execute job completion.

func NewExecuteTask

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

Initialize task with fields needed to query server nodes.

func (*ExecuteTask) IsDone

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

Query all nodes for task completion status.

func (*ExecuteTask) OnComplete

func (etsk *ExecuteTask) OnComplete() chan error

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
	//BIN FieldType = 3;
	DIGEST_RIPE FieldType = 4
	//GU_TID FieldType = 5;
	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

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

Query filter definition.

func NewEqualFilter

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

Create equality filter for query.

func NewRangeFilter

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

Create range filter for query. Range arguments must be longs or integers which can be cast to longs. String ranges are not supported.

type GenerationPolicy

type GenerationPolicy int

How to handle record writes based on record generation.

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

	// Update/delete record if expected generation is equal to server generation. Otherwise, fail.
	EXPECT_GEN_EQUAL

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

	// Create duplicate record if expected generation is not equal to server generation.
	// Duplicates are only created when the server configuration option "allow-versions"
	// is true (default is false).
	DUPLICATE
)

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

Initialize host.

func (*Host) String

func (h *Host) String() string

Implements stringer interface

type IndexTask

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

Task used to poll for long running create index completion.

func NewIndexTask

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

func (*IndexTask) IsDone

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

Query all nodes for task completion status.

func (*IndexTask) OnComplete

func (tski *IndexTask) OnComplete() chan error

type IndexType

type IndexType string

Type of secondary index.

const (
	// Number index.
	NUMERIC IndexType = "NUMERIC"

	// String index.
	STRING IndexType = "STRING"
)

type IntegerValue

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

Integer value.

func NewIntegerValue

func NewIntegerValue(value int) *IntegerValue

func (*IntegerValue) GetObject

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

func (*IntegerValue) GetType

func (vl *IntegerValue) GetType() int

func (*IntegerValue) String

func (vl *IntegerValue) String() string

type Key

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

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)

Initialize 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 (*Key) Digest

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

Returns current key digest

func (*Key) Equals

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

Uses key digests to compare key equality.

func (*Key) Namespace

func (ky *Key) Namespace() string

returns Namespace

func (*Key) SetName

func (ky *Key) SetName() string

Returns Set name

func (*Key) String

func (ky *Key) String() string

Return string representation of key.

func (*Key) Value

func (ky *Key) Value() Value

Returns key's value

type Language

type Language string

User defined function languages.

const (

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

type LargeList

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

Create and manage a list within a single bin. /

func NewLargeList

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

Initialize large list operator.

client client policy generic configuration parameters, pass in nil for defaults key unique record identifier binName bin name userModule Lua function name that initializes list configuration parameters, pass nil for default list

func (*LargeList) Add

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

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

values values to add

func (*LargeList) Destroy

func (ll *LargeList) Destroy() error

Delete bin containing the list.

func (*LargeList) Filter

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

Select values from list and apply specified Lua filter.

filterName Lua function name which applies filter to returned list filterArgs arguments to Lua function name returns list of entries selected

func (*LargeList) Find

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

Select values from list.

value value to select returns list of entries selected

func (*LargeList) FindThenFilter

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

Select values from list and apply specified Lua filter.

value value to select filterName Lua function name which applies filter to returned list filterArgs arguments to Lua function name returns list of entries selected

func (*LargeList) GetCapacity

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

Return maximum number of entries in the list.

func (*LargeList) GetConfig

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

Return map of list configuration parameters.

func (*LargeList) Remove

func (ll *LargeList) Remove(value interface{}) error

Delete value from list.

value value to delete

func (*LargeList) Scan

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

Return all objects in the list.

func (*LargeList) SetCapacity

func (ll *LargeList) SetCapacity(capacity int) error

Set maximum number of entries in the list.

capacity max entries in list

func (*LargeList) Size

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

Return size of list.

type LargeMap

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

Create and manage a map within a single bin.

func NewLargeMap

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

Initialize large map operator.

client client policy generic configuration parameters, pass in nil for defaults key unique record identifier binName bin name userModule Lua function name that initializes list configuration parameters, pass nil for default set

func (*LargeMap) Destroy

func (lm *LargeMap) Destroy() error

Delete bin containing the list.

func (*LargeMap) Filter

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

Select items from map.

filterName Lua function name which applies filter to returned list filterArgs arguments to Lua function name return list of items selected

func (*LargeMap) Get

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

Get value from map given name key.

name key. return map of items selected

func (*LargeMap) GetCapacity

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

Return maximum number of entries in the list.

func (*LargeMap) GetConfig

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

Return map of list configuration parameters.

func (*LargeMap) Put

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

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

name entry key value entry value

func (*LargeMap) PutMap

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

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

map map values to push

func (*LargeMap) Scan

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

Return all objects in the list.

func (*LargeMap) SetCapacity

func (lm *LargeMap) SetCapacity(capacity int) error

Set maximum number of entries in the list.

capacity max entries in list

func (*LargeMap) Size

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

Return size of list.

type LargeObject

type LargeObject interface {
	Destroy() error
	Size() (int, error)
	GetConfig() (map[interface{}]interface{}, error)
	SetCapacity(capacity int) error
	GetCapacity() (int, error)
	// contains filtered or unexported methods
}

type LargeSet

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

Create and manage a set within a single bin.

func NewLargeSet

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

func (*LargeSet) Add

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

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

values values to add

func (*LargeSet) Destroy

func (ls *LargeSet) Destroy() error

Delete bin containing the list.

func (*LargeSet) Exists

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

Check existence of value in the set.

value value to check returns true if found, otherwise false

func (*LargeSet) Filter

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

Select values from set and apply specified Lua filter.

filterName Lua function name which applies filter to returned list filterArgs arguments to Lua function name returns list of entries selected

func (*LargeSet) Get

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

Select value from set.

value value to select returns found value

func (*LargeSet) GetCapacity

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

Return maximum number of entries in the list.

func (*LargeSet) GetConfig

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

Return map of list configuration parameters.

func (*LargeSet) Remove

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

Delete value from set.

value value to delete

func (*LargeSet) Scan

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

func (*LargeSet) SetCapacity

func (ls *LargeSet) SetCapacity(capacity int) error

Set maximum number of entries in the list.

capacity max entries in list

func (*LargeSet) Size

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

Return size of list.

type LargeStack

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

Create and manage a stack within a single bin. A stack is last in/first out (LIFO).

func NewLargeStack

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

Initialize large stack operator.

client client policy generic configuration parameters, pass in nil for defaults key unique record identifier binName bin name userModule Lua function name that initializes list configuration parameters, pass nil for default set

func (*LargeStack) Destroy

func (lstk *LargeStack) Destroy() error

Delete bin containing the list.

func (*LargeStack) Filter

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

Select items from top of stack.

peekCount number of items to select. filterName Lua function name which applies filter to returned list filterArgs arguments to Lua function name returns list of items selected

func (*LargeStack) GetCapacity

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

Return maximum number of entries in the list.

func (*LargeStack) GetConfig

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

Return map of list configuration parameters.

func (*LargeStack) Peek

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

Select items from top of stack.

peekCount number of items to select. returns list of items selected

func (*LargeStack) Pop

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

Select items from top of stack.

peekCount number of items to select. returns list of items selected

func (*LargeStack) Push

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

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

values values to push

func (*LargeStack) Scan

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

Return all objects in the list.

func (*LargeStack) SetCapacity

func (lstk *LargeStack) SetCapacity(capacity int) error

Set maximum number of entries in the list.

capacity max entries in list

func (*LargeStack) Size

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

Return size of list.

type ListValue

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

List value. Supported by Aerospike 3 servers only.

func NewListValue

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

func (*ListValue) GetObject

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

func (*ListValue) GetType

func (vl *ListValue) GetType() int

func (*ListValue) String

func (vl *ListValue) String() string

type LongValue

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

Long value.

func NewLongValue

func NewLongValue(value int64) *LongValue

func (*LongValue) GetObject

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

func (*LongValue) GetType

func (vl *LongValue) GetType() int

func (*LongValue) String

func (vl *LongValue) String() string

type MapValue

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

Map value. Supported by Aerospike 3 servers only.

func NewMapValue

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

func (*MapValue) GetObject

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

func (*MapValue) GetType

func (vl *MapValue) GetType() int

func (*MapValue) String

func (vl *MapValue) String() string

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)

Adds an alias for the node

func (*Node) Close

func (nd *Node) Close()

Marks node as inactice and closes all cached connections

func (*Node) DecreaseHealth

func (nd *Node) DecreaseHealth()

Decrease node Health as a result of bad connection or communication

func (*Node) Equals

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

func (*Node) GetAliases

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

Returns node aliases

func (*Node) GetConnection

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

Get a connection to the node. If no cached connection is not available, a new connection will be created

func (*Node) GetHost

func (nd *Node) GetHost() *Host

Retrieves host for the node

func (*Node) GetName

func (nd *Node) GetName() string

Returns node name

func (*Node) IsActive

func (nd *Node) IsActive() bool

Checks if the node is active

func (*Node) IsUnhealthy

func (nd *Node) IsUnhealthy() bool

Check if the node is unhealthy

func (*Node) MigrationInProgress

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)

Put back a connection to the cache. If cache is full, the connection will be closed and discarded

func (*Node) Refresh

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

Request current status from server node, and update node with the result

func (*Node) RestoreHealth

func (nd *Node) RestoreHealth()

Mark the node as healthy

func (*Node) String

func (nd *Node) String() string

Implements stringer interface

func (*Node) WaitUntillMigrationIsFinished

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

type NodeError

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

func (*NodeError) Node

func (ne *NodeError) Node() *Node

type NullValue

type NullValue struct{}

func NewNullValue

func NewNullValue() *NullValue

func (*NullValue) GetObject

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

func (*NullValue) GetType

func (vl *NullValue) GetType() int

func (*NullValue) String

func (vl *NullValue) String() string

type Operation

type Operation struct {

	// Type of operation.
	OpType OperationType

	// Optional bin name used in operation.
	BinName *string

	// Optional bin value used in operation.
	BinValue Value
}

Database operation definition. The class is used in client's operate() method.

func AddOp

func AddOp(bin *Bin) *Operation

Create integer add database operation.

func AppendOp

func AppendOp(bin *Bin) *Operation

Create string append database operation.

func GetHeaderOp

func GetHeaderOp() *Operation

Create read record header database operation.

func GetOp

func GetOp() *Operation

Create read all record bins database operation.

func GetOpForBin

func GetOpForBin(binName string) *Operation

Create read bin database operation.

func PrependOp

func PrependOp(bin *Bin) *Operation

Create string prepend database operation.

func PutOp

func PutOp(bin *Bin) *Operation

Create set database operation.

func TouchOp

func TouchOp() *Operation

Create touch database operation.

type OperationType

type OperationType int

Aerospike operation type

var (
	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
}

func NewPartition

func NewPartition(namespace string, partitionId int) *Partition

func NewPartitionByKey

func NewPartitionByKey(key *Key) *Partition

func (*Partition) Equals

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

func (*Partition) String

func (ptn *Partition) String() string

type Policy

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

Policy Interface

type Priority

type Priority int

Priority of operations on database server.

const (

	// The server defines the priority.
	DEFAULT Priority = iota

	// Run the database operation in a background thread.
	LOW

	// Run the database operation at medium priority.
	MEDIUM

	// Run the database operation at the highest priority.
	HIGH
)

type QueryPolicy

type QueryPolicy 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
}

Container object for policy attributes used in query operations.

func NewQueryPolicy

func NewQueryPolicy() *QueryPolicy

type Record

type Record struct {
	// Record's Key. Might be empty, or only consist of digest only.
	Key *Key

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

	// Map of requested name/value bins.
	Bins BinMap

	// List of all duplicate records (if any) for a given key.  Duplicates are only created when
	// the server configuration option "allow-versions" is true (default is false) and client
	// RecordExistsAction.DUPLICATE policy flag is set and there is a generation error.
	// Almost always nil.
	Duplicates []BinMap

	// Record modification count.
	Generation int

	// Date record will expire, in seconds from Jan 01 2010 00:00:00 GMT
	Expiration int
}

Container object for records. Records are equivalent to rows.

func (*Record) String

func (rc *Record) String() string

Return string representation of record.

type RecordExistsAction

type RecordExistsAction int

How to handle writes when the record already exists.

const (

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

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

	// 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 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.  Fail if record exists.
	CREATE_ONLY
)

type Recordset

type Recordset struct {
	Records chan *Record
	Errors  chan error
	// contains filtered or unexported fields
}

func NewRecordset

func NewRecordset(size int) *Recordset

func (*Recordset) Close

func (rcs *Recordset) Close()

Close all commands

func (*Recordset) IsActive

func (rcs *Recordset) IsActive() bool

type RegisterTask

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

Task used to poll for UDF registration completion.

func NewRegisterTask

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

Initialize task with fields needed to query server nodes.

func (*RegisterTask) IsDone

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

Query all nodes for task completion status.

func (*RegisterTask) OnComplete

func (tskr *RegisterTask) OnComplete() chan error

type RemoveTask

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

Task used to poll for UDF registration completion.

func NewRemoveTask

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

Initialize task with fields needed to query server nodes.

func (*RemoveTask) IsDone

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

Query all nodes for task completion status.

func (*RemoveTask) OnComplete

func (tskr *RemoveTask) OnComplete() chan error

type ScanPolicy

type ScanPolicy struct {
	BasePolicy

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

	// 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 scan requests
	// will be made to 8 nodes in parallel.  When a scan completes, a new scan request will
	// be issued until all 16 nodes have been scanned.
	//
	// This field is only relevant when concurrentNodes is true.
	// Default (0) is to issue requests to all server nodes in parallel.
	MaxConcurrentNodes int

	// Issue scan requests in parallel or serially.
	ConcurrentNodes bool //= true;

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

	// Terminate scan if cluster in fluctuating state.
	FailOnClusterChange bool

	// 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
}

Container object for optional parameters used in scan operations.

func NewScanPolicy

func NewScanPolicy() *ScanPolicy

type Statement

type Statement struct {
	// Query Namespace
	Namespace string

	// Query Set name (optional)
	SetName string

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

	// bin names (optional)
	BinNames []string

	// Optional query filters.
	// 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

	// Set optional query task id.
	TaskId int
	// contains filtered or unexported fields
}

Query statement parameters.

func NewStatement

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

func (*Statement) Addfilter

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

Add a filter to the statement

func (*Statement) IsScan

func (stmt *Statement) IsScan() bool

Return if full namespace/set scan is specified.

func (*Statement) SetAggregateFunction

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

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

type StringValue

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

value string.

func NewStringValue

func NewStringValue(value string) *StringValue

func (*StringValue) GetObject

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

func (*StringValue) GetType

func (vl *StringValue) GetType() int

func (*StringValue) String

func (vl *StringValue) String() string

type Task

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

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

type UDF

type UDF struct {
	Filename string
	Hash     string
	Language Language
}

UDFInfo carries information about UDFs on the server

type Value

type Value interface {

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

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

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

Polymorphic value classes used to efficiently serialize objects into the wire protocol.

func NewValue

func NewValue(v interface{}) Value

type ValueArray

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

Value array. Supported by Aerospike 3 servers only.

func NewValueArray

func NewValueArray(array []Value) *ValueArray

func ToValueArray

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

func (*ValueArray) GetObject

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

func (*ValueArray) GetType

func (vl *ValueArray) GetType() int

func (*ValueArray) String

func (vl *ValueArray) String() string

type WritePolicy

type WritePolicy struct {
	BasePolicy

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

	// Qualify 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;

	// 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 int

	// Record expiration. 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 int

	// 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
}

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

func NewWritePolicy

func NewWritePolicy(generation, expiration int) *WritePolicy

Directories

Path Synopsis
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