types

package
v1.34.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSG_HEADER_SIZE = 8 //sizeof(MessageHeader)

	MSG_INFO    messageType = 1
	MSG_MESSAGE             = 3
)
View Source
const (
	// citrusleaf epoc: Jan 01 2010 00:00:00 GMT
	CITRUSLEAF_EPOCH = 1262304000
)

Variables

View Source
var ErrRecordsetClosed = NewAerospikeError(RECORDSET_CLOSED, "Recordset has already been closed.")

Functions

func KeepConnection

func KeepConnection(err error) bool

Should connection be put back into pool.

func NewAerospikeError

func NewAerospikeError(code ResultCode, messages ...string) error

NewAerospikeError generates a new AerospikeError instance. If no message is provided, the result code will be translated into the default error message automatically. To be able to check for error type, you could use the following:

if aerr, ok := err.(AerospikeError); ok {
    errCode := aerr.ResultCode()
    errMessage := aerr.Error()
}

func ResultCodeToString

func ResultCodeToString(resultCode ResultCode) string

Return result code as a string.

func TTL

func TTL(secsFromCitrusLeafEpoc uint32) uint32

TTL converts an Expiration time from citrusleaf epoc to TTL in seconds.

Types

type AerospikeError

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

AerospikeError implements error interface for aerospike specific errors. All errors returning from the library are of this type. Errors resulting from Go's stdlib are not translated to this type, unless they are a net.Timeout error.

func (AerospikeError) InDoubt added in v1.32.0

func (ase AerospikeError) InDoubt() bool

InDoubt determines if a write transaction may have completed or not.

func (*AerospikeError) MarkInDoubt added in v1.32.0

func (ase *AerospikeError) MarkInDoubt()

MarkInDoubt marks an error as in doubt.

func (AerospikeError) ResultCode

func (ase AerospikeError) ResultCode() ResultCode

ResultCode returns the ResultCode from AerospikeError object.

func (*AerospikeError) SetInDoubt added in v1.32.0

func (ase *AerospikeError) SetInDoubt(isRead bool, commandSentCounter int)

SetInDoubt sets whether it is possible that the write transaction may have completed even though this error was generated. This may be the case when a client error occurs (like timeout) after the command was sent to the server.

type BufferPool added in v1.0.1

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

BufferPool implements a specialized buffer pool. Pool size will be limited, and each buffer size will be constrained to the init and max buffer sizes.

func NewBufferPool added in v1.0.1

func NewBufferPool(poolSize, initBufferSize, maxBufferSize int) *BufferPool

NewBufferPool creates a new buffer pool. New buffers will be created with size and capacity of initBufferSize. If cap(buffer) is larger than maxBufferSize when it is put back in the buffer, it will be thrown away. This will prevent unwanted memory bloat and set a deterministic maximum-size for the pool which will not be exceeded.

func (*BufferPool) Get added in v1.0.1

func (bp *BufferPool) Get() (res []byte)

Get returns a buffer from the pool. If pool is empty, a new buffer of size initBufSize will be created and returned.

func (*BufferPool) Put added in v1.0.1

func (bp *BufferPool) Put(buf []byte)

Put will put the buffer back in the pool, unless cap(buf) is bigger than initBufSize, in which case it will be thrown away

type Message

type Message struct {
	MessageHeader

	Data []byte
}

func NewMessage

func NewMessage(mtype messageType, data []byte) *Message

NewMessage generates a new Message instance.

func (*Message) Resize

func (msg *Message) Resize(newSize int64) error

Resize changes the internal buffer size for the message.

func (*Message) Serialize

func (msg *Message) Serialize() []byte

Serialize returns a byte slice containing the message.

type MessageHeader

type MessageHeader struct {
	Version uint8
	Type    uint8
	DataLen [6]byte
}

func (*MessageHeader) Length

func (msg *MessageHeader) Length() int64

Length returns the length of the message

type Pool added in v1.0.1

type Pool struct {

	// New will create a new object
	New func(params ...interface{}) interface{}
	// IsUsable checks if the object polled from the pool is still fresh and usable
	IsUsable func(obj interface{}, params ...interface{}) bool
	// CanReturn checkes if the object is eligible to go back to the pool
	CanReturn func(obj interface{}) bool
	// Finalize will be called when an object is not eligible to go back to the pool.
	// Usable to close connections, file handles, ...
	Finalize func(obj interface{})
	// contains filtered or unexported fields
}

Pool implements a general purpose fixed-size pool.

func NewPool added in v1.0.1

func NewPool(poolSize int) *Pool

NewPool creates a new fixed size pool.

func (*Pool) Get added in v1.0.1

func (bp *Pool) Get(params ...interface{}) interface{}

Get returns an element from the pool. If the pool is empty, or the returned element is not usable, nil or the result of the New function will be returned

func (*Pool) Put added in v1.0.1

func (bp *Pool) Put(obj interface{})

Put will add the elem back to the pool, unless the pool is full.

type ResultCode

type ResultCode int

ResultCode signifies the database operation error codes. The positive numbers align with the server side file proto.h.

const (
	// Cluster has an invalid partition map, usually due to bad configuration.
	INVALID_CLUSTER_PARTITION_MAP ResultCode = -12

	// Server is not accepting requests.
	SERVER_NOT_AVAILABLE ResultCode = -11

	// Cluster Name does not match the ClientPolicy.ClusterName value.
	CLUSTER_NAME_MISMATCH_ERROR ResultCode = -10

	// Recordset has already been closed or cancelled
	RECORDSET_CLOSED ResultCode = -9

	// There were no connections available to the node in the pool, and the pool was limited
	NO_AVAILABLE_CONNECTIONS_TO_NODE ResultCode = -8

	// Data type is not supported by aerospike server.
	TYPE_NOT_SUPPORTED ResultCode = -7

	// Info Command was rejected by the server.
	COMMAND_REJECTED ResultCode = -6

	// Query was terminated by user.
	QUERY_TERMINATED ResultCode = -5

	// Scan was terminated by user.
	SCAN_TERMINATED ResultCode = -4

	// Chosen node is not currently active.
	INVALID_NODE_ERROR ResultCode = -3

	// Client parse error.
	PARSE_ERROR ResultCode = -2

	// Client serialization error.
	SERIALIZE_ERROR ResultCode = -1

	// Operation was successful.
	OK ResultCode = 0

	// Unknown server failure.
	SERVER_ERROR ResultCode = 1

	// On retrieving, touching or replacing a record that doesn't exist.
	KEY_NOT_FOUND_ERROR ResultCode = 2

	// On modifying a record with unexpected generation.
	GENERATION_ERROR ResultCode = 3

	// Bad parameter(s) were passed in database operation call.
	PARAMETER_ERROR ResultCode = 4

	// On create-only (write unique) operations on a record that already
	// exists.
	KEY_EXISTS_ERROR ResultCode = 5

	// On create-only (write unique) operations on a bin that already
	// exists.
	BIN_EXISTS_ERROR ResultCode = 6

	// Expected cluster ID was not received.
	CLUSTER_KEY_MISMATCH ResultCode = 7

	// Server has run out of memory.
	SERVER_MEM_ERROR ResultCode = 8

	// Client or server has timed out.
	TIMEOUT ResultCode = 9

	// Operation not allowed in current configuration.
	ALWAYS_FORBIDDEN ResultCode = 10

	// Partition is unavailable.
	PARTITION_UNAVAILABLE ResultCode = 11

	// Operation is not supported with configured bin type (single-bin or
	// multi-bin).
	BIN_TYPE_ERROR ResultCode = 12

	// Record size exceeds limit.
	RECORD_TOO_BIG ResultCode = 13

	// Too many concurrent operations on the same record.
	KEY_BUSY ResultCode = 14

	// Scan aborted by server.
	SCAN_ABORT ResultCode = 15

	// Unsupported Server Feature (e.g. Scan + UDF)
	UNSUPPORTED_FEATURE ResultCode = 16

	// Specified bin name does not exist in record.
	BIN_NOT_FOUND ResultCode = 17

	// Device not keeping up with writes.
	DEVICE_OVERLOAD ResultCode = 18

	// Key type mismatch.
	KEY_MISMATCH ResultCode = 19

	// Invalid namespace.
	INVALID_NAMESPACE ResultCode = 20

	// Bin name length greater than 14 characters,
	// or maximum number of unique bin names are exceeded.
	BIN_NAME_TOO_LONG ResultCode = 21

	// Operation not allowed at this time.
	FAIL_FORBIDDEN ResultCode = 22

	// Element Not Found in CDT
	FAIL_ELEMENT_NOT_FOUND ResultCode = 23

	// Element Already Exists in CDT
	FAIL_ELEMENT_EXISTS ResultCode = 24

	// There are no more records left for query.
	QUERY_END ResultCode = 50

	// Security type not supported by connected server.
	SECURITY_NOT_SUPPORTED ResultCode = 51

	// Administration command is invalid.
	SECURITY_NOT_ENABLED ResultCode = 52

	// Administration field is invalid.
	SECURITY_SCHEME_NOT_SUPPORTED ResultCode = 53

	// Administration command is invalid.
	INVALID_COMMAND ResultCode = 54

	// Administration field is invalid.
	INVALID_FIELD ResultCode = 55

	// Security protocol not followed.
	ILLEGAL_STATE ResultCode = 56

	// User name is invalid.
	INVALID_USER ResultCode = 60

	// User was previously created.
	USER_ALREADY_EXISTS ResultCode = 61

	// Password is invalid.
	INVALID_PASSWORD ResultCode = 62

	// Security credential is invalid.
	EXPIRED_PASSWORD ResultCode = 63

	// Forbidden password (e.g. recently used)
	FORBIDDEN_PASSWORD ResultCode = 64

	// Security credential is invalid.
	INVALID_CREDENTIAL ResultCode = 65

	// Role name is invalid.
	INVALID_ROLE ResultCode = 70

	// Role already exists.
	ROLE_ALREADY_EXISTS ResultCode = 71

	// Privilege is invalid.
	INVALID_PRIVILEGE ResultCode = 72

	// User must be authentication before performing database operations.
	NOT_AUTHENTICATED ResultCode = 80

	// User does not posses the required role to perform the database operation.
	ROLE_VIOLATION ResultCode = 81

	// A user defined function returned an error code.
	UDF_BAD_RESPONSE ResultCode = 100

	// The requested item in a large collection was not found.
	LARGE_ITEM_NOT_FOUND ResultCode = 125

	// Batch functionality has been disabled.
	BATCH_DISABLED ResultCode = 150

	// Batch max requests have been exceeded.
	BATCH_MAX_REQUESTS_EXCEEDED ResultCode = 151

	// All batch queues are full.
	BATCH_QUEUES_FULL ResultCode = 152

	// Invalid GeoJSON on insert/update
	GEO_INVALID_GEOJSON ResultCode = 160

	// Secondary index already exists.
	INDEX_FOUND ResultCode = 200

	// Requested secondary index does not exist.
	INDEX_NOTFOUND ResultCode = 201

	// Secondary index memory space exceeded.
	INDEX_OOM ResultCode = 202

	// Secondary index not available.
	INDEX_NOTREADABLE ResultCode = 203

	// Generic secondary index error.
	INDEX_GENERIC ResultCode = 204

	// Index name maximum length exceeded.
	INDEX_NAME_MAXLEN ResultCode = 205

	// Maximum number of indexes exceeded.
	INDEX_MAXCOUNT ResultCode = 206

	// Secondary index query aborted.
	QUERY_ABORTED ResultCode = 210

	// Secondary index queue full.
	QUERY_QUEUEFULL ResultCode = 211

	// Secondary index query timed out on server.
	QUERY_TIMEOUT ResultCode = 212

	// Generic query error.
	QUERY_GENERIC ResultCode = 213

	// Query NetIO error on server
	QUERY_NETIO_ERR ResultCode = 214

	// Duplicate TaskId sent for the statement
	QUERY_DUPLICATE ResultCode = 215

	// UDF does not exist.
	AEROSPIKE_ERR_UDF_NOT_FOUND ResultCode = 1301

	// LUA file does not exist.
	AEROSPIKE_ERR_LUA_FILE_NOT_FOUND ResultCode = 1302
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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