Categorygithub.com/sparrc/aerospike-client-go
modulepackage
1.16.3
Repository: https://github.com/sparrc/aerospike-client-go.git
Documentation: pkg.go.dev

# README

Aerospike Go Client

Aerospike Client Go

An Aerospike library for Go.

This library is compatible with Go 1.5+ 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.5+ is required.

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, Red Hat)
  • Mac OS X
  • Windows (untested)

Installation:

  1. Install Go 1.5+ 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.in is also supported: go get -u gopkg.in/aerospike/aerospike-client-go.v1

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

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.

# Packages

* Copyright 2012-2016 Aerospike, Inc.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddOp creates integer add database operation.
AppendOp creates string append database operation.
DefaultMapPolicy returns the default map policy.
GetHeaderOp creates read record header database operation.
GetOp creates read all record bins database operation.
GetOpForBin creates read bin database operation.
ListAppendOp creates a list append operation.
ListClearOp creates a list clear operation.
ListGetOp creates a list get operation.
ListGetRangeFromOp creates a list get range operation.
ListGetRangeOp creates a list get range operation.
ListInsertOp creates a list insert operation.
ListPopOp creates list pop operation.
ListPopRangeFromOp creates a list pop range operation.
ListPopRangeOp creates a list pop range operation.
ListRemoveOp creates a list remove operation.
ListRemoveRangeFromOp creates a list remove range operation.
ListRemoveRangeOp creates a list remove range operation.
ListSetOp creates a list set operation.
ListSizeOp creates a list size operation.
ListTrimOp creates a list trim operation.
MapClearOp creates map clear operation.
MapDecrementOp creates map decrement operation.
MapGetByIndexOp creates map get by index operation.
MapGetByIndexRangeCountOp creates map get by index range operation.
MapGetByIndexRangeOp creates map get by index range operation.
MapGetByKeyOp creates map get by key operation.
MapGetByKeyRangeOp creates map get by key range operation.
MapGetByRankOp creates map get by rank operation.
MapGetByRankRangeCountOp creates map get by rank range operation.
MapGetByRankRangeOp creates map get by rank range operation.
MapGetByValueOp creates map get by value operation.
MapGetByValueRangeOp creates map get by value range operation.
MapIncrementOp creates map increment operation.
MapPutItemsOp creates map put items operation Server writes each map item to map bin and returns map size.
MapPutOp creates map put operation.
MapRemoveByIndexOp creates map remove operation.
MapRemoveByIndexRangeCountOp creates map remove operation.
MapRemoveByIndexRangeOp creates map remove operation.
MapRemoveByKeyListOp creates map remove operation.
MapRemoveByKeyOp creates map remove operation.
MapRemoveByKeyRangeOp creates map remove operation.
MapRemoveByRankOp creates map remove operation.
MapRemoveByRankRangeCountOp creates map remove operation.
MapRemoveByRankRangeOp creates map remove operation.
MapRemoveByValueListOp creates map remove operation.
MapRemoveByValueOp creates map remove operation.
MapRemoveByValueRangeOp creates map remove operation.
MapSetPolicyOp creates set map policy operation.
MapSizeOp creates map size operation.
NewAdminPolicy generates a new AdminPolicy with default values.
NewBin generates a new Bin instance, specifying bin name and string value.
NewBlobValue accepts an AerospikeBlob interface, and automatically converts it to a BytesValue.
NewBytesValue generates a ByteValue instance.
NewClient generates a new Client instance.
NewClientPolicy generates a new ClientPolicy with default values.
NewClientWithPolicy generates a new Client using the specified ClientPolicy.
NewClientWithPolicyAndHost generates a new Client the specified ClientPolicy and sets up the cluster using the provided hosts.
NewCluster generates a Cluster instance.
NewConnection creates a connection on the network and returns the pointer A minimum timeout of 2 seconds will always be applied.
NewContainsFilter creates a contains filter for query on collection index.
NewContainsRangeFilter creates a contains filter for query on ranges of data in a collection index.
NewEqualFilter creates a new equality filter instance for query.
NewExecuteTask initializes task with fields needed to query server nodes.
NewFloatValue generates a FloatValue instance.
NewMapValue generates a GeoJSONValue instance.
NewGeoRegionsContainingPointFilter creates a geospatial "containing point" filter for query.
collectionType creates a geospatial "containing point" filter for query on collection index.
NewGeoWithinRadiusFilter creates a geospatial "within radius" filter for query.
NewGeoWithinRadiusForCollectionFilter creates a geospatial "within radius" filter for query on collection index.
NewGeoWithinRegionFilter creates a geospatial "within region" filter for query.
NewGeoWithinRegionForCollectionFilter creates a geospatial "within region" filter for query on collection index.
NewHost initializes new host instance.
NewIndexTask initializes a task with fields needed to query server nodes.
NewIntegerValue generates an IntegerValue instance.
NewKey initializes a key from namespace, optional set name and user key.
NewKeyWithDigest initializes a key from namespace, optional set name and user key.
NewLargeList initializes a large list operator.
NewLargeMap initializes a large map operator.
NewLargeSet initializes a large set operator.
NewLargeStack initializes a large stack operator.
NewListValue generates a ListValue instance.
NewLongValue generates a LongValue instance.
Create unique key map with specified order when map does not exist.
NewMapValue generates a MapValue instance.
NewMultiPolicy initializes a MultiPolicy instance with default values.
NewNullValue generates a NullValue instance.
NewPartition generates a partition instance.
NewPartitionByKey initializes a partition and determines the Partition Id from key digest automatically.
NewPolicy generates a new BasePolicy instance with default values.
NewQueryPolicy generates a new QueryPolicy instance with default values.
NewRangeFilter creates a range filter for query.
NewRegisterTask initializes a RegisterTask with fields needed to query server nodes.
NewRemoveTask initializes a RemoveTask with fields needed to query server nodes.
NewScanPolicy creates a new ScanPolicy instance with default values.
NewStatement initializes a new Statement instance.
NewStringValue generates a StringValue instance.
NewTask initializes task with fields needed to query server nodes.
NewValue generates a new Value object based on the type.
NewValueArray generates a ValueArray instance.
NewWritePolicy initializes a new WritePolicy instance with default parameters.
PrependOp creates string prepend database operation.
PutOp creates set database operation.
RequestInfo gets info values by name from the specified connection.
RequestNodeInfo gets info values by name from the specified database server node.
RequestNodeStats returns statistics for the specified node as a map.
SetCommandBufferPool can be used to customize the command Buffer Pool parameters to calibrate the pool for different workloads.
SetLuaPath sets the Lua interpreter path to files This path is used to load UDFs for QueryAggregate command.
TouchOp creates touch database operation.
ToValueArray converts a []interface{} to a ValueArray type.
ToValueSlice converts a []interface{} to []Value.

# Constants

COMMIT_ALL indicates the server should wait until successfully committing master and all replicas.
COMMIT_MASTER indicates the server should wait until successfully committing master only.
CONSISTENCY_ALL indicates that all replicas should be consulted in the read operation.
CONSISTENCY_ONE indicates only a single replica should be consulted in the read operation.
CREATE_ONLY means: Create only.
DEFAULT determines that the server defines the priority.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
EXPECT_GEN_EQUAL means: Update/Delete record if expected generation is equal to server generation.
EXPECT_GEN_GT means: Update/Delete record if expected generation greater than the server generation.
2-dimensional spherical geospatial index.
HIGH determines that the server should run the operation at the highest priority.
Normal scalar index.
LIST is Index list elements.
MAPKEYS is Index map keys.
MAPVALUES is Index map values.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
LOW determines that the server should run the operation in a background thread.
LUA embedded programming language.
MEDIUM determines that the server should run the operation at medium priority.
FieldType constants used in the Aerospike Wire Protocol.
NONE means: Do not use record generation to restrict writes.
NUMERIC specifies an index on numeric values.
FieldType constants used in the Aerospike Wire Protocol.
Read allow read transactions with the database.
ReadWrite allows read and write transactions with the database.
ReadWriteUDF allows read, write and UDF transactions with the database.
REPLACE means: Create or replace record.
REPLACE_ONLY means: Replace record only.
FieldType constants used in the Aerospike Wire Protocol.
STRING specifies an index on string values.
SysAdmin allows to manage indexes, user defined functions and server configuration.
FieldType constants used in the Aerospike Wire Protocol.
user supplied transaction id, which is simply passed back.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
FieldType constants used in the Aerospike Wire Protocol.
UPDATE means: Create or update record.
UPDATE_ONLY means: Update record only.
UserAdmin allows to manages users and their roles.

# Variables

Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.
Map storage order.
Map return type.
No description provided by the author
10 MB.
Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.
Valid OperationType values that can be used to create custom Operations.

# Structs

No description provided by the author
AdminPolicy contains attributes used for user administration commands.
BasePolicy encapsulates parameters for transaction policy attributes used in all database operation calls.
BaseTask is used to poll for server task completion.
Bin encapsulates a field name/value pair.
Client encapsulates an Aerospike cluster.
ClientPolicy encapsulates parameters for client policy command.
Cluster encapsulates the aerospike cluster nodes and manages them.
Connection represents a connection with a timeout.
ExecuteTask is used to poll for long running server execute job completion.
Filter specifies a query filter definition.
Host name/port of database server.
IndexTask is used to poll for long running create index completion.
Key is the unique record identifier.
LargeList encapsulates a list within a single bin.
LargeMap encapsulates a map within a single bin.
LargeSet encapsulates a set within a single bin.
LargeStack encapsulates a stack within a single bin.
ListValue encapsulates any arbitrary array.
Map pair is used when the client returns sorted maps from the server Since the default map in Go is a hash map, we will use a slice to return the results in server order.
MapPolicy directives when creating a map and writing map items.
MapValue encapsulates an arbitrary map.
MultiPolicy contains parameters for policy attributes used in query and scan operations.
Node represents an Aerospike Database Server Node.
NodeError is a type to encapsulate the node that the error occurred in.
NullValue is an empty value.
Operation contains operation definition.
Partition encapsulates partition information.
QueryPolicy encapsulates parameters for policy attributes used in query operations.
Record is the container struct for database records.
Recordset encapsulates the result of Scan and Query commands.
RegisterTask is used to poll for UDF registration completion.
RemoveTask is used to poll for UDF registration completion.
No description provided by the author
ScanPolicy encapsulates parameters used in scan operations.
Statement encapsulates query statement parameters.
UDF carries information about UDFs on the server.
UserRoles contains information about a user.
ValueArray encapsulates an array of Value.
WritePolicy encapsulates parameters for policy attributes used in write operations.

# Interfaces

AerospikeBlob defines an interface to automatically encode an object to a []byte.
LargeObject interface defines methods to work with LDTs.
Policy Interface.
Task interface defines methods for asynchronous tasks.
Value interface is used to efficiently serialize objects into the wire protocol.

# Type aliases

BinMap is used to define a map of bin names to values.
BytesValue encapsulates an array of bytes.
CommitLevel indicates the desired consistency guarantee when committing a transaction on the server.
ConsistencyLevel indicates how replicas should be consulted in a read operation to provide the desired consistency guarantee.
FieldType represents the type of the field in Aerospike Wire Protocol.
FloatValue encapsulates an float64 value.
GenerationPolicy determines how to handle record writes based on record generation.
MapValue encapsulates a 2D Geo point.
IndexCollectionType is the secondary index collection type.
IndexType the type of the secondary index.
IntegerValue encapsulates an integer value.
Language specifies User defined function languages.
LongValue encapsulates an int64 value.
Priority of operations on database server.
RecordExistsAction determines how to handle writes when the record already exists.
No description provided by the author
StringValue encapsulates a string value.