aerospike

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HLLBin = "hll"

	MaxIndexBits          = 13 // between 4 and 16
	MaxAllowedMinhashBits = 8  // between 4 and 51

)
View Source
const (
	EnvPrefix = "AEROSPIKE"
)

EnvPrefix environment prefix for mongodb config

Variables

View Source
var (
	ErrConnectionIsNotSet = errors.New("connection is not set")
)

All kind of errors for aerospike

Functions

func CreateClientPolicy

func CreateClientPolicy(cfg *ConnectionConfig) *aero.ClientPolicy

CreateClientPolicy creates policy for production

func Default

func Default(names ...string) (*aero.Client, error)

Default return default AerospikeInterface

func Get

func Get(name string) (*aero.Client, error)

Get return aerospike connection

func NewBin

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

func NewValue

func NewValue(value interface{}) aero.Value

func Set

func Set(name string, r *aero.Client)

Set set global connection

Types

type Aerospike

type Aerospike interface {
	IsConnected() bool
	GetNodeNames() []string
	Put(*aerospike.WritePolicy, *aerospike.Key, aerospike.BinMap) aerospike.Error
	PutBins(*aerospike.WritePolicy, *aerospike.Key, ...*aerospike.Bin) aerospike.Error
	Query(*aerospike.QueryPolicy, *aerospike.Statement) (*aerospike.Recordset, aerospike.Error)

	CreateIndex(*aerospike.WritePolicy,
		string,
		string,
		string,
		string,
		aerospike.IndexType,
	) (*aerospike.IndexTask, aerospike.Error)

	DropIndex(
		policy *aerospike.WritePolicy,
		namespace string,
		setName string,
		indexName string,
	) aerospike.Error

	CreateComplexIndex(
		*aerospike.WritePolicy,
		string,
		string,
		string,
		string,
		aerospike.IndexType,
		aerospike.IndexCollectionType,
		...*aerospike.CDTContext,
	) (*aerospike.IndexTask, aerospike.Error)

	Stats() (map[string]interface{}, aerospike.Error)
	Get(*aerospike.BasePolicy, *aerospike.Key, ...string) (*aerospike.Record, aerospike.Error)
	Operate(*aerospike.WritePolicy, *aerospike.Key, ...*aerospike.Operation) (*aerospike.Record, aerospike.Error)
	Delete(
		policy *aerospike.WritePolicy,
		key *aerospike.Key,
	) (bool, aerospike.Error)
	BatchDelete(
		policy *aerospike.BatchPolicy,
		deletePolicy *aerospike.BatchDeletePolicy,
		keys []*aerospike.Key,
	) ([]*aerospike.BatchRecord, aerospike.Error)
	BatchGet(*aerospike.BatchPolicy, []*aerospike.Key, ...string) ([]*aerospike.Record, aerospike.Error)
	RegisterUDF(
		policy *aerospike.WritePolicy,
		udfBody []byte,
		serverPath string,
		language aerospike.Language,
	) (*aerospike.RegisterTask, aerospike.Error)
	RegisterUDFFromFile(
		policy *aerospike.WritePolicy,
		clientPath string,
		serverPath string,
		language aerospike.Language,
	) (*aerospike.RegisterTask, aerospike.Error)
	ExecuteUDF(
		policy *aerospike.QueryPolicy,
		statement *aerospike.Statement,
		packageName string,
		functionName string,
		functionArgs ...aerospike.Value,
	) (*aerospike.ExecuteTask, aerospike.Error)
	QueryAggregate(
		policy *aerospike.QueryPolicy,
		statement *aerospike.Statement,
		packageName, functionName string,
		functionArgs ...aerospike.Value,
	) (*aerospike.Recordset, aerospike.Error)
	Exists(policy *aerospike.BasePolicy, key *aerospike.Key) (bool, aerospike.Error)

	Truncate(policy *aerospike.InfoPolicy, namespace, set string, beforeLastUpdate *time.Time) aerospike.Error
	BatchOperate(policy *aerospike.BatchPolicy, records []aerospike.BatchRecordIfc) aerospike.Error
}

type ConnectionConfig

type ConnectionConfig struct {
	Host                string   `env:"_HOST" envDefault:"127.0.0.1"`
	Username            string   `env:"_USERNAME" envDefault:""`
	Password            string   `env:"_PASSWORD" envDefault:""`
	Hosts               []string `env:"_HOSTS" envDefault:""`
	Port                int      `env:"_PORT" envDefault:"3000"`
	ConnectionQueueSize int      `env:"_CONNECTION_QUEUE_SIZE" envDefault:"1000"`
}

ConnectionConfig contains required data for mongo

func GetConnectionConfigFromEnv

func GetConnectionConfigFromEnv(prefix string) (*ConnectionConfig, error)

GetConnectionConfigFromEnv return aerospike configs bases on environment variables

type Mapper

type Mapper interface {
	ToMap() map[string]interface{}
}

type Namespace

type Namespace interface {
	Put(*aerospike.WritePolicy, string, interface{}, aerospike.BinMap) aerospike.Error
	PutBins(policy *aerospike.WritePolicy, setName string, value interface{}, bins ...*aerospike.Bin) aerospike.Error
	Query(*aerospike.QueryPolicy, *aerospike.Statement) (*aerospike.Recordset, aerospike.Error)

	CreateIndex(
		policy *aerospike.WritePolicy,
		set string,
		indexName string,
		fieldName string,
		indexType aerospike.IndexType,
	) (*aerospike.IndexTask, aerospike.Error)

	DropIndex(
		policy *aerospike.WritePolicy,
		setName string,
		indexName string,
	) aerospike.Error

	CreateComplexIndex(
		policy *aerospike.WritePolicy,
		set string,
		indexName string,
		field string,
		indexType aerospike.IndexType,
		collectionType aerospike.IndexCollectionType,
		ctx ...*aerospike.CDTContext,
	) (*aerospike.IndexTask, aerospike.Error)

	Stats() (map[string]interface{}, aerospike.Error)
	Get(
		policy *aerospike.BasePolicy,
		setName string,
		value interface{},
		binNames ...string,
	) (*aerospike.Record, aerospike.Error)
	Operate(
		policy *aerospike.WritePolicy,
		setName string,
		value interface{},
		ops ...*aerospike.Operation,
	) (*aerospike.Record, aerospike.Error)
	Delete(
		policy *aerospike.WritePolicy,
		setName string,
		value interface{},
	) (bool, aerospike.Error)
	BatchDelete(
		policy *aerospike.BatchPolicy,
		deletePolicy *aerospike.BatchDeletePolicy,
		values []SetKey,
	) ([]*aerospike.BatchRecord, aerospike.Error)
	BatchGet(*aerospike.BatchPolicy, []SetKey, ...string) ([]*aerospike.Record, aerospike.Error)
	QueryAggregate(
		policy *aerospike.QueryPolicy,
		statement *aerospike.Statement,
		packageName, functionName string,
		functionArgs ...aerospike.Value,
	) (*aerospike.Recordset, aerospike.Error)
	Exists(*aerospike.BasePolicy, string, interface{}) (bool, aerospike.Error)

	Truncate(policy *aerospike.InfoPolicy, set string, beforeLastUpdate *time.Time) aerospike.Error
	GetConnection() Aerospike
	GetNamespace() string
	BatchOperate(policy *aerospike.BatchPolicy, records []aerospike.BatchRecordIfc) aerospike.Error
}

type NamespaceInstance

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

func NewNamespaceInstance

func NewNamespaceInstance(namespace string, names ...string) (*NamespaceInstance, error)

func (*NamespaceInstance) BatchDelete

func (ni *NamespaceInstance) BatchDelete(
	policy *aero.BatchPolicy,
	deletePolicy *aero.BatchDeletePolicy,
	values []SetKey,
) ([]*aero.BatchRecord, aero.Error)

func (*NamespaceInstance) BatchGet

func (ni *NamespaceInstance) BatchGet(
	policy *aero.BatchPolicy,
	values []SetKey,
	names ...string,
) ([]*aero.Record, aero.Error)

func (*NamespaceInstance) BatchOperate

func (ni *NamespaceInstance) BatchOperate(policy *aero.BatchPolicy, records []aero.BatchRecordIfc) aero.Error

func (*NamespaceInstance) CreateComplexIndex

func (ni *NamespaceInstance) CreateComplexIndex(
	policy *aero.WritePolicy,
	setName string,
	indexName string,
	binName string,
	indexType aero.IndexType,
	indexCollectionType aero.IndexCollectionType,
	ctx ...*aero.CDTContext,
) (*aero.IndexTask, aero.Error)

func (*NamespaceInstance) CreateIndex

func (ni *NamespaceInstance) CreateIndex(
	policy *aero.WritePolicy,
	setName string,
	indexName string,
	binName string,
	indexType aero.IndexType,
) (*aero.IndexTask, aero.Error)

func (*NamespaceInstance) Delete

func (ni *NamespaceInstance) Delete(policy *aero.WritePolicy, setName string, value interface{}) (bool, aero.Error)

func (*NamespaceInstance) DropIndex

func (ni *NamespaceInstance) DropIndex(
	policy *aero.WritePolicy,
	setName string,
	indexName string,
) aero.Error

func (*NamespaceInstance) Exists

func (ni *NamespaceInstance) Exists(policy *aero.BasePolicy, setName string, value interface{}) (bool, aero.Error)

func (*NamespaceInstance) Get

func (ni *NamespaceInstance) Get(
	policy *aero.BasePolicy,
	setName string,
	value interface{},
	binNames ...string,
) (*aero.Record, aero.Error)

func (*NamespaceInstance) GetConnection

func (ni *NamespaceInstance) GetConnection() *aero.Client

func (*NamespaceInstance) GetNamespace

func (ni *NamespaceInstance) GetNamespace() string

func (*NamespaceInstance) Operate

func (ni *NamespaceInstance) Operate(
	policy *aero.WritePolicy,
	setName string,
	value interface{},
	ops ...*aero.Operation,
) (*aero.Record, aero.Error)

func (*NamespaceInstance) Put

func (ni *NamespaceInstance) Put(
	policy *aero.WritePolicy,
	setName string,
	value interface{},
	bins aero.BinMap,
) aero.Error

func (*NamespaceInstance) PutBins

func (ni *NamespaceInstance) PutBins(
	policy *aero.WritePolicy,
	setName string,
	value interface{},
	bins ...*aero.Bin,
) aero.Error

func (*NamespaceInstance) Query

func (ni *NamespaceInstance) Query(policy *aero.QueryPolicy, stmt *aero.Statement) (*aero.Recordset, aero.Error)

func (*NamespaceInstance) QueryAggregate

func (ni *NamespaceInstance) QueryAggregate(
	policy *aero.QueryPolicy,
	statement *aero.Statement,
	packageName, functionName string,
	functionArgs ...aero.Value,
) (*aero.Recordset, aero.Error)

func (*NamespaceInstance) Stats

func (ni *NamespaceInstance) Stats() (map[string]interface{}, aero.Error)

func (*NamespaceInstance) Truncate

func (ni *NamespaceInstance) Truncate(policy *aero.InfoPolicy, set string, beforeLastUpdate *time.Time) aero.Error

type SetKey

type SetKey struct {
	Key interface{}
	Set string
}

Directories

Path Synopsis
mocks
Package mock_entity is a generated GoMock package.
Package mock_entity is a generated GoMock package.
Package mock_aerospike is a generated GoMock package.
Package mock_aerospike is a generated GoMock package.

Jump to

Keyboard shortcuts

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