Documentation
¶
Overview ¶
Package aerospike provides Aerospike client and namespace helpers.
New code should depend on core-owned operation contracts where possible:
import "github.com/InsideGallery/core/db/aerospike"
Use NamespaceStore with Key, PutOptions, GetOptions, DeleteOptions, Record, RecordResult, and Result for record operations that should not expose Aerospike SDK types. Use NewConnection or ConnectionRegistry.Default when the consuming application owns client lifecycle explicitly.
Compatibility: the legacy Aerospike and Namespace interfaces, NamespaceInstance SDK-shaped methods, and package-level Default connection helper remain available for existing consumers.
Index ¶
- Constants
- Variables
- func CreateClientPolicy(cfg *ConnectionConfig) *aero.ClientPolicy
- func Default(names ...string) (*aero.Client, error)deprecated
- func Get(name string) (*aero.Client, error)deprecated
- func NewBin(name string, value interface{}) *aero.Bin
- func NewConnection(config *ConnectionConfig) (*aero.Client, error)
- func NewConnectionFromEnv(prefix string) (*aero.Client, error)
- func NewValue(value interface{}) aero.Value
- func Set(name string, r *aero.Client)deprecated
- func Setup(architecture BufferArchitecture)
- type Aerospikedeprecated
- type BufferArchitecture
- type ConnectionConfig
- type ConnectionRegistry
- type DeleteOptions
- type GetOptions
- type Key
- type Mapper
- type Namespacedeprecated
- type NamespaceInstance
- func (ni *NamespaceInstance) BatchDelete(policy *aero.BatchPolicy, deletePolicy *aero.BatchDeletePolicy, ...) ([]*aero.BatchRecord, aero.Error)
- func (ni *NamespaceInstance) BatchGet(policy *aero.BatchPolicy, values []SetKey, names ...string) ([]*aero.Record, aero.Error)
- func (ni *NamespaceInstance) BatchOperate(policy *aero.BatchPolicy, records []aero.BatchRecordIfc) aero.Error
- func (ni *NamespaceInstance) CreateComplexIndex(policy *aero.WritePolicy, setName string, indexName string, binName string, ...) (*aero.IndexTask, aero.Error)
- func (ni *NamespaceInstance) CreateIndex(policy *aero.WritePolicy, setName string, indexName string, binName string, ...) (*aero.IndexTask, aero.Error)
- func (ni *NamespaceInstance) Delete(policy *aero.WritePolicy, setName string, value interface{}) (bool, aero.Error)
- func (ni *NamespaceInstance) DeleteRecord(ctx context.Context, options DeleteOptions) (Result, error)
- func (ni *NamespaceInstance) DropIndex(policy *aero.WritePolicy, setName string, indexName string) aero.Error
- func (ni *NamespaceInstance) Exists(policy *aero.BasePolicy, setName string, value interface{}) (bool, aero.Error)
- func (ni *NamespaceInstance) Get(policy *aero.BasePolicy, setName string, value interface{}, binNames ...string) (*aero.Record, aero.Error)
- func (ni *NamespaceInstance) GetConnection() *aero.Client
- func (ni *NamespaceInstance) GetNamespace() string
- func (ni *NamespaceInstance) GetRecord(ctx context.Context, options GetOptions) (RecordResult, error)
- func (ni *NamespaceInstance) Operate(policy *aero.WritePolicy, setName string, value interface{}, ...) (*aero.Record, aero.Error)
- func (ni *NamespaceInstance) Put(policy *aero.WritePolicy, setName string, value interface{}, bins aero.BinMap) aero.Error
- func (ni *NamespaceInstance) PutBins(policy *aero.WritePolicy, setName string, value interface{}, bins ...*aero.Bin) aero.Error
- func (ni *NamespaceInstance) PutRecord(ctx context.Context, options PutOptions) (Result, error)
- func (ni *NamespaceInstance) Query(policy *aero.QueryPolicy, stmt *aero.Statement) (*aero.Recordset, aero.Error)
- func (ni *NamespaceInstance) QueryAggregate(policy *aero.QueryPolicy, statement *aero.Statement, ...) (*aero.Recordset, aero.Error)
- func (ni *NamespaceInstance) Stats() (map[string]interface{}, aero.Error)
- func (ni *NamespaceInstance) Truncate(policy *aero.InfoPolicy, set string, beforeLastUpdate *time.Time) aero.Error
- type NamespaceStore
- type PutOptions
- type Record
- type RecordResult
- type Result
- type SetKey
Constants ¶
const ( HLLBin = "hll" MaxIndexBits = 13 // between 4 and 16 MaxAllowedMinhashBits = 8 // between 4 and 51 )
const (
EnvPrefix = "AEROSPIKE"
)
EnvPrefix environment prefix for mongodb config
Variables ¶
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 NewConnection ¶ added in v1.1.0
func NewConnection(config *ConnectionConfig) (*aero.Client, error)
NewConnection creates an Aerospike client from explicit config.
func NewConnectionFromEnv ¶ added in v1.1.0
NewConnectionFromEnv creates an Aerospike client from an explicit environment prefix.
func Setup ¶ added in v1.1.0
func Setup(architecture BufferArchitecture)
Setup disables Aerospike buffer architecture flags for int64 compatibility.
Types ¶
type Aerospike
deprecated
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
}
Aerospike is the legacy Aerospike SDK-shaped client contract.
Deprecated: use NamespaceStore and core-owned option/result types for new code.
type BufferArchitecture ¶ added in v1.1.0
BufferArchitecture exposes Aerospike buffer architecture flags as explicit dependencies.
func DefaultBufferArchitecture ¶ added in v1.1.0
func DefaultBufferArchitecture() BufferArchitecture
DefaultBufferArchitecture returns the Aerospike package buffer architecture flags.
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 ConnectionRegistry ¶ added in v1.1.0
type ConnectionRegistry struct {
// contains filtered or unexported fields
}
ConnectionRegistry owns Aerospike clients for explicit application composition.
func NewConnectionRegistry ¶ added in v1.1.0
func NewConnectionRegistry() *ConnectionRegistry
NewConnectionRegistry creates an isolated Aerospike connection registry.
func (*ConnectionRegistry) Close ¶ added in v1.1.0
func (r *ConnectionRegistry) Close() error
Close closes all clients stored in this registry and clears it.
func (*ConnectionRegistry) Default ¶ added in v1.1.0
func (r *ConnectionRegistry) Default(name string, config *ConnectionConfig) (*aero.Client, error)
Default returns or creates a registry-scoped Aerospike client from explicit config.
type DeleteOptions ¶ added in v1.1.0
type DeleteOptions struct {
Key Key
}
DeleteOptions is the core-owned input for deleting a record.
type GetOptions ¶ added in v1.1.0
GetOptions is the core-owned input for reading a record.
type Namespace
deprecated
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
}
Namespace is the legacy namespace contract that exposes Aerospike SDK types.
Deprecated: use NamespaceStore and core-owned option/result types for new code.
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 (*NamespaceInstance) Delete ¶
func (ni *NamespaceInstance) Delete(policy *aero.WritePolicy, setName string, value interface{}) (bool, aero.Error)
func (*NamespaceInstance) DeleteRecord ¶ added in v1.1.0
func (ni *NamespaceInstance) DeleteRecord(ctx context.Context, options DeleteOptions) (Result, error)
DeleteRecord deletes a record through a core-owned input and result shape.
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) GetRecord ¶ added in v1.1.0
func (ni *NamespaceInstance) GetRecord(ctx context.Context, options GetOptions) (RecordResult, error)
GetRecord reads a record through a core-owned input and result shape.
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) PutRecord ¶ added in v1.1.0
func (ni *NamespaceInstance) PutRecord(ctx context.Context, options PutOptions) (Result, error)
PutRecord writes a record through a core-owned input and result shape.
func (*NamespaceInstance) Query ¶
func (ni *NamespaceInstance) Query(policy *aero.QueryPolicy, stmt *aero.Statement) (*aero.Recordset, aero.Error)
func (*NamespaceInstance) QueryAggregate ¶
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 NamespaceStore ¶ added in v1.1.0
type NamespaceStore interface {
PutRecord(ctx context.Context, options PutOptions) (Result, error)
GetRecord(ctx context.Context, options GetOptions) (RecordResult, error)
DeleteRecord(ctx context.Context, options DeleteOptions) (Result, error)
}
NamespaceStore is the core-owned namespace contract for new consumers.
type PutOptions ¶ added in v1.1.0
PutOptions is the core-owned input for writing a record.
type RecordResult ¶ added in v1.1.0
RecordResult reports a record lookup result.