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

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

# Packages

* Copyright 2012-2014 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.
GetHeaderOp creates read record header database operation.
GetOp creates read all record bins database operation.
GetOpForBin creates read bin database 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.
NewEqualFilter creates a new equality filter instance for query.
NewExecuteTask initializes task with fields needed to query server nodes.
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.
NewKey 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.
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.
TouchOp creates touch database operation.
ToValueArray converts a []interface{} to []Value.

# Constants

No description provided by the author
No description provided by the author
Server should wait until successfully committing master and all replicas.
Server should wait until successfully committing master only.
Involve all replicas in the operation.
Involve a single replica in the operation.
CREATE_ONLY means: Create only.
DEFAULT determines that the server defines the priority.
No description provided by the author
No description provided by the author
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.
HIGH determines that the server should run the operation at the highest priority.
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
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.
No description provided by the author
NONE means: Do not use record generation to restrict writes.
NUMERIC specifies an index on numeric values.
No description provided by the author
No description provided by the author
Allow read transactions with the database.
No description provided by the author
Allow read and write transactions with the database.
REPLACE means: Create or replace record.
REPLACE_ONLY means: Replace record only.
No description provided by the author
STRING specifies an index on string values.
Manage indicies, user defined functions and server configuration.
No description provided by the author
No description provided by the author
user supplied transaction id, which is simply passed back.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
UPDATE means: Create or update record.
UPDATE_ONLY means: Update record only.
Manage users their roles.
READ_HEADER OperationType = 1.

# Structs

No description provided by the author
Policy attributes used for user administration commands.
BasePolicy excapsulates 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 arbitray array.
MapValue encapsulates an arbitray 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 occured in.
NullValue is an empty value.
Operation contasins 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.
No description provided by the author
UDF carries information about UDFs on the server.
User and assigned roles.
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.
Desired consistency guarantee when committing a transaction on the server.
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.
GenerationPolicy determines how to handle record writes based on record generation.
IndexType the type of the secondary index.
IntegerValue encapsulates an integer value.
Language specifies User defined function languages.
LongValue encapsulates an int64 value.
OperationType determines operation type.
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.