types

package
v4.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MSG_HEADER_SIZE is a message's header size
	MSG_HEADER_SIZE = 8

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

Variables

View Source
var (
	ErrServerNotAvailable             = NewAerospikeError(SERVER_NOT_AVAILABLE)
	ErrKeyNotFound                    = NewAerospikeError(KEY_NOT_FOUND_ERROR)
	ErrRecordsetClosed                = NewAerospikeError(RECORDSET_CLOSED)
	ErrConnectionPoolEmpty            = NewAerospikeError(NO_AVAILABLE_CONNECTIONS_TO_NODE, "Connection pool is empty. This happens when either all connection are in-use already, or no connections were available")
	ErrTooManyConnectionsForNode      = NewAerospikeError(NO_AVAILABLE_CONNECTIONS_TO_NODE, "Connection limit reached for this node. This value is controlled via ClientPolicy.LimitConnectionsToQueueSize")
	ErrTooManyOpeningConnections      = NewAerospikeError(NO_AVAILABLE_CONNECTIONS_TO_NODE, "Too many connections are trying to open at once. This value is controlled via ClientPolicy.OpeningConnectionThreshold")
	ErrTimeout                        = NewAerospikeError(TIMEOUT, "command execution timed out on client: See `Policy.Timeout`")
	ErrUDFBadResponse                 = NewAerospikeError(UDF_BAD_RESPONSE, "Invalid UDF return value")
	ErrNoOperationsSpecified          = NewAerospikeError(INVALID_COMMAND, "No operations were passed to QueryExecute")
	ErrNoBinNamesAlloedInQueryExecute = NewAerospikeError(INVALID_COMMAND, "Statement.BinNames must be empty for QueryExecute")
	ErrFilteredOut                    = NewAerospikeError(FILTERED_OUT)
	ErrPartitionScanQueryNotSupported = NewAerospikeError(PARAMETER_ERROR, "Partition Scans/Queries are not supported by all nodes in this cluster")
	ErrScanTerminated                 = NewAerospikeError(SCAN_TERMINATED)
	ErrQueryTerminated                = NewAerospikeError(QUERY_TERMINATED)
)

Functions

func KeepConnection

func KeepConnection(err error) bool

KeepConnection decides if a connection should be kept based on the error type.

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

ResultCodeToString returns a human readable errors message based on the result code.

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
}

Message encapsulates a message sent or received from the Aerospike server

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, error)

Serialize returns a byte slice containing the message.

type MessageHeader

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

MessageHeader is the message's header

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 (
	// MAX_RETRIES_EXCEEDED defines max retries limit reached.
	MAX_RETRIES_EXCEEDED ResultCode = -16

	// MAX_ERROR_RATE defines max errors limit reached.
	MAX_ERROR_RATE ResultCode = -15

	// RACK_NOT_DEFINED defines requested Rack for node/namespace was not defined in the cluster.
	RACK_NOT_DEFINED ResultCode = -13

	// INVALID_CLUSTER_PARTITION_MAP defines cluster has an invalid partition map, usually due to bad configuration.
	INVALID_CLUSTER_PARTITION_MAP ResultCode = -12

	// SERVER_NOT_AVAILABLE defines server is not accepting requests.
	SERVER_NOT_AVAILABLE ResultCode = -11

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

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

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

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

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

	// QUERY_TERMINATED defines query was terminated by user.
	QUERY_TERMINATED ResultCode = -5

	// SCAN_TERMINATED defines scan was terminated by user.
	SCAN_TERMINATED ResultCode = -4

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

	// PARSE_ERROR defines client parse error.
	PARSE_ERROR ResultCode = -2

	// SERIALIZE_ERROR defines client serialization error.
	SERIALIZE_ERROR ResultCode = -1

	// OK defines operation was successful.
	OK ResultCode = 0

	// SERVER_ERROR defines unknown server failure.
	SERVER_ERROR ResultCode = 1

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

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

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

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

	// BIN_EXISTS_ERROR defines bin already exists on a create-only operation.
	BIN_EXISTS_ERROR ResultCode = 6

	// CLUSTER_KEY_MISMATCH defines expected cluster ID was not received.
	CLUSTER_KEY_MISMATCH ResultCode = 7

	// SERVER_MEM_ERROR defines server has run out of memory.
	SERVER_MEM_ERROR ResultCode = 8

	// TIMEOUT defines client or server has timed out.
	TIMEOUT ResultCode = 9

	// ALWAYS_FORBIDDEN defines operation not allowed in current configuration.
	ALWAYS_FORBIDDEN ResultCode = 10

	// PARTITION_UNAVAILABLE defines partition is unavailable.
	PARTITION_UNAVAILABLE ResultCode = 11

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

	// RECORD_TOO_BIG defines record size exceeds limit.
	RECORD_TOO_BIG ResultCode = 13

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

	// SCAN_ABORT defines scan aborted by server.
	SCAN_ABORT ResultCode = 15

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

	// BIN_NOT_FOUND defines bin not found on update-only operation.
	BIN_NOT_FOUND ResultCode = 17

	// DEVICE_OVERLOAD defines device not keeping up with writes.
	DEVICE_OVERLOAD ResultCode = 18

	// KEY_MISMATCH defines key type mismatch.
	KEY_MISMATCH ResultCode = 19

	// INVALID_NAMESPACE defines invalid namespace.
	INVALID_NAMESPACE ResultCode = 20

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

	// FAIL_FORBIDDEN defines operation not allowed at this time.
	FAIL_FORBIDDEN ResultCode = 22

	// FAIL_ELEMENT_NOT_FOUND defines element Not Found in CDT
	FAIL_ELEMENT_NOT_FOUND ResultCode = 23

	// FAIL_ELEMENT_EXISTS defines element Already Exists in CDT
	FAIL_ELEMENT_EXISTS ResultCode = 24

	// ENTERPRISE_ONLY defines attempt to use an Enterprise feature on a Community server or a server
	// without the applicable feature key.
	ENTERPRISE_ONLY ResultCode = 25

	// OP_NOT_APPLICABLE defines the operation cannot be applied to the current bin value on the server.
	OP_NOT_APPLICABLE ResultCode = 26

	// FILTERED_OUT defines the transaction was not performed because the filter was false.
	FILTERED_OUT ResultCode = 27

	// LOST_CONFLICT defines write command loses conflict to XDR.
	LOST_CONFLICT = 28

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

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

	// SECURITY_NOT_ENABLED defines administration command is invalid.
	SECURITY_NOT_ENABLED ResultCode = 52

	// SECURITY_SCHEME_NOT_SUPPORTED defines administration field is invalid.
	SECURITY_SCHEME_NOT_SUPPORTED ResultCode = 53

	// INVALID_COMMAND defines administration command is invalid.
	INVALID_COMMAND ResultCode = 54

	// INVALID_FIELD defines administration field is invalid.
	INVALID_FIELD ResultCode = 55

	// ILLEGAL_STATE defines security protocol not followed.
	ILLEGAL_STATE ResultCode = 56

	// INVALID_USER defines user name is invalid.
	INVALID_USER ResultCode = 60

	// USER_ALREADY_EXISTS defines user was previously created.
	USER_ALREADY_EXISTS ResultCode = 61

	// INVALID_PASSWORD defines password is invalid.
	INVALID_PASSWORD ResultCode = 62

	// EXPIRED_PASSWORD defines security credential is invalid.
	EXPIRED_PASSWORD ResultCode = 63

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

	// INVALID_CREDENTIAL defines security credential is invalid.
	INVALID_CREDENTIAL ResultCode = 65

	// EXPIRED_SESSION defines login session expired.
	EXPIRED_SESSION ResultCode = 66

	// INVALID_ROLE defines role name is invalid.
	INVALID_ROLE ResultCode = 70

	// ROLE_ALREADY_EXISTS defines role already exists.
	ROLE_ALREADY_EXISTS ResultCode = 71

	// INVALID_PRIVILEGE defines privilege is invalid.
	INVALID_PRIVILEGE ResultCode = 72

	// INVALID_WHITELIST defines invalid IP address whiltelist
	INVALID_WHITELIST = 73

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

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

	// NOT_WHITELISTED defines command not allowed because sender IP address not whitelisted.
	NOT_WHITELISTED = 82

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

	// BATCH_DISABLED defines batch functionality has been disabled.
	BATCH_DISABLED ResultCode = 150

	// BATCH_MAX_REQUESTS_EXCEEDED defines batch max requests have been exceeded.
	BATCH_MAX_REQUESTS_EXCEEDED ResultCode = 151

	// BATCH_QUEUES_FULL defines all batch queues are full.
	BATCH_QUEUES_FULL ResultCode = 152

	// GEO_INVALID_GEOJSON defines invalid GeoJSON on insert/update
	GEO_INVALID_GEOJSON ResultCode = 160

	// INDEX_FOUND defines secondary index already exists.
	INDEX_FOUND ResultCode = 200

	// INDEX_NOTFOUND defines requested secondary index does not exist.
	INDEX_NOTFOUND ResultCode = 201

	// INDEX_OOM defines secondary index memory space exceeded.
	INDEX_OOM ResultCode = 202

	// INDEX_NOTREADABLE defines secondary index not available.
	INDEX_NOTREADABLE ResultCode = 203

	// INDEX_GENERIC defines generic secondary index error.
	INDEX_GENERIC ResultCode = 204

	// INDEX_NAME_MAXLEN defines index name maximum length exceeded.
	INDEX_NAME_MAXLEN ResultCode = 205

	// INDEX_MAXCOUNT defines maximum number of indexes exceeded.
	INDEX_MAXCOUNT ResultCode = 206

	// QUERY_ABORTED defines secondary index query aborted.
	QUERY_ABORTED ResultCode = 210

	// QUERY_QUEUEFULL defines secondary index queue full.
	QUERY_QUEUEFULL ResultCode = 211

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

	// QUERY_GENERIC defines generic query error.
	QUERY_GENERIC ResultCode = 213

	// QUERY_NETIO_ERR defines query NetIO error on server
	QUERY_NETIO_ERR ResultCode = 214

	// QUERY_DUPLICATE defines duplicate TaskId sent for the statement
	QUERY_DUPLICATE ResultCode = 215

	// AEROSPIKE_ERR_UDF_NOT_FOUND defines uDF does not exist.
	AEROSPIKE_ERR_UDF_NOT_FOUND ResultCode = 1301

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