bindings

package
v4.19.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ANY     = 0
	EQ      = 1
	LT      = 2
	LE      = 3
	GT      = 4
	GE      = 5
	RANGE   = 6
	SET     = 7
	ALLSET  = 8
	EMPTY   = 9
	LIKE    = 10
	DWITHIN = 11

	ERROR   = 1
	WARNING = 2
	INFO    = 3
	TRACE   = 4

	AggSum         = 0
	AggAvg         = 1
	AggFacet       = 2
	AggMin         = 3
	AggMax         = 4
	AggDistinct    = 5
	AggCount       = 6
	AggCountCached = 7

	CollateNone    = 0
	CollateASCII   = 1
	CollateUTF8    = 2
	CollateNumeric = 3
	CollateCustom  = 4
)

public go consts from type_consts.h and reindexer_ctypes.h

View Source
const (
	OpOr  = 1
	OpAnd = 2
	OpNot = 3

	ValueInt64     = 0
	ValueDouble    = 1
	ValueString    = 2
	ValueBool      = 3
	ValueNull      = 4
	ValueInt       = 8
	ValueUndefined = 9
	ValueComposite = 10
	ValueTuple     = 11
	ValueUuid      = 12

	QueryCondition              = 0
	QueryDistinct               = 1
	QuerySortIndex              = 2
	QueryJoinOn                 = 3
	QueryLimit                  = 4
	QueryOffset                 = 5
	QueryReqTotal               = 6
	QueryDebugLevel             = 7
	QueryAggregation            = 8
	QuerySelectFilter           = 9
	QuerySelectFunction         = 10
	QueryEnd                    = 11
	QueryExplain                = 12
	QueryEqualPosition          = 13
	QueryUpdateField            = 14
	QueryAggregationLimit       = 15
	QueryAggregationOffset      = 16
	QueryAggregationSort        = 17
	QueryOpenBracket            = 18
	QueryCloseBracket           = 19
	QueryJoinCondition          = 20
	QueryDropField              = 21
	QueryUpdateObject           = 22
	QueryWithRank               = 23
	QueryStrictMode             = 24
	QueryUpdateFieldV2          = 25
	QueryBetweenFieldsCondition = 26
	QueryAlwaysFalseCondition   = 27
	QueryAlwaysTrueCondition    = 28
	QuerySubQueryCondition      = 29
	QueryFieldSubQueryCondition = 30

	LeftJoin    = 0
	InnerJoin   = 1
	OrInnerJoin = 2
	Merge       = 3

	CacheModeOn         = 0
	CacheModeAggressive = 1
	CacheModeOff        = 2

	FormatJson  = 0
	FormatCJson = 1

	ModeUpdate = 0
	ModeInsert = 1
	ModeUpsert = 2
	ModeDelete = 3

	ModeNoCalc        = 0
	ModeCachedTotal   = 1
	ModeAccurateTotal = 2

	QueryResultEnd             = 0
	QueryResultAggregation     = 1
	QueryResultExplain         = 2
	QueryResultShardingVersion = 3
	QueryResultShardId         = 4
	QueryResultIncarnationTags = 5

	QueryStrictModeNotSet  = 0
	QueryStrictModeNone    = 1
	QueryStrictModeNames   = 2
	QueryStrictModeIndexes = 3

	ResultsFormatMask = 0xF
	ResultsPure       = 0x0
	ResultsPtrs       = 0x1
	ResultsCJson      = 0x2
	ResultsJson       = 0x3

	ResultsWithPayloadTypes   = 0x10
	ResultsWithItemID         = 0x20
	ResultsWithPercents       = 0x40
	ResultsWithNsID           = 0x80
	ResultsWithJoined         = 0x100
	ResultsWithShardId        = 0x800
	ResultsSupportIdleTimeout = 0x2000

	IndexOptPK         = 1 << 7
	IndexOptArray      = 1 << 6
	IndexOptDense      = 1 << 5
	IndexOptAppendable = 1 << 4
	IndexOptSparse     = 1 << 3

	StorageOptEnabled               = 1
	StorageOptDropOnFileFormatError = 1 << 1
	StorageOptCreateIfMissing       = 1 << 2

	ConnectOptOpenNamespaces       = 1
	ConnectOptAllowNamespaceErrors = 1 << 1
	ConnectOptAutorepair           = 1 << 2
	ConnectOptWarnVersion          = 1 << 4

	BindingCapabilityQrIdleTimeouts        = 1
	BindingCapabilityResultsWithShardIDs   = 1 << 1
	BindingCapabilityNamespaceIncarnations = 1 << 2

	ErrOK                   = 0
	ErrParseSQL             = 1
	ErrQueryExec            = 2
	ErrParams               = 3
	ErrLogic                = 4
	ErrParseJson            = 5
	ErrParseDSL             = 6
	ErrConflict             = 7
	ErrParseBin             = 8
	ErrForbidden            = 9
	ErrWasRelock            = 10
	ErrNotValid             = 11
	ErrNetwork              = 12
	ErrNotFound             = 13
	ErrStateInvalidated     = 14
	ErrTimeout              = 19
	ErrCanceled             = 20
	ErrTagsMissmatch        = 21
	ErrReplParams           = 22
	ErrNamespaceInvalidated = 23
	ErrParseMsgPack         = 24
	ErrParseProtobuf        = 25
	ErrUpdatesLost          = 26
	ErrWrongReplicationData = 27
	ErrUpdateReplication    = 28
	ErrClusterConsensus     = 29
	ErrTerminated           = 30
	ErrTxDoesNotExist       = 31
	ErrAlreadyConnected     = 32
	ErrTxInvalidLeader      = 33
	ErrAlreadyProxied       = 34
	ErrStrictMode           = 35
	ErrQrUIDMissmatch       = 36
	ErrSystem               = 37
	ErrAssert               = 38
)

private go consts from type_consts.h and reindexer_ctypes.h

View Source
const (
	ReplicationTypeCluster = "cluster"
	ReplicationTypeAsync   = "async_replication"
)
View Source
const (
	ShardingNotSet   = -1
	ShardingProxyOff = -2
)
View Source
const (
	StorageTypeLevelDB = 0
	StorageTypeRocksDB = 1
)
View Source
const (
	EventTypeNone                      = 0
	EventTypeItemUpdate                = 1
	EventTypeItemUpsert                = 2
	EventTypeItemDelete                = 3
	EventTypeItemInsert                = 4
	EventTypeItemUpdateTx              = 5
	EventTypeItemUpsertTx              = 6
	EventTypeItemDeleteTx              = 7
	EventTypeItemInsertTx              = 8
	EventTypeIndexAdd                  = 9
	EventTypeIndexDrop                 = 10
	EventTypeIndexUpdate               = 11
	EventTypePutMeta                   = 12
	EventTypePutMetaTx                 = 13
	EventTypeUpdateQuery               = 14
	EventTypeDeleteQuery               = 15
	EventTypeUpdateQueryTx             = 16
	EventTypeDeleteQueryTx             = 17
	EventTypeSetSchema                 = 18
	EventTypeTruncate                  = 19
	EventTypeBeginTx                   = 20
	EventTypeCommitTx                  = 21
	EventTypeAddNamespace              = 22
	EventTypeDropNamespace             = 23
	EventTypeCloseNamespace            = 24
	EventTypeRenameNamespace           = 25
	EventTypeResyncNamespaceGeneric    = 26
	EventTypeResyncNamespaceLeaderInit = 27
	EventTypeResyncOnUpdatesDrop       = 28
	EventTypeEmptyUpdate               = 29
	EventTypeNodeNetworkCheck          = 30
	EventTypeSetTagsMatcher            = 31
	EventTypeSetTagsMatcherTx          = 32
	EventTypeSaveShardingConfig        = 33
	EventTypeApplyShardingConfig       = 34
	EventTypeResetOldShardingConfig    = 35
	EventTypeResetCandidateConfig      = 36
	EventTypeRollbackCandidateConfig   = 37
	EventTypeDeleteMeta                = 38
)
View Source
const (
	SubscriptionTypeNamespaces = 0
	SubscriptionTypeDatabase   = 1
)
View Source
const CInt32Max = int(^uint32(0) >> 1)
View Source
const ReindexerVersion = "v4.19.0"
View Source
const (
	SubscriptionDataTypeNone = "none"
)

Variables

This section is empty.

Functions

func CreateInt64FromLSN added in v4.16.0

func CreateInt64FromLSN(v LsnT) int64

func NewError

func NewError(text string, code int) error

func RegisterBinding

func RegisterBinding(name string, binding RawBinding)

Types

type BindingCapabilities

type BindingCapabilities struct {
	Value int64
}

Capabilties of chosen binding. This value will affect some of the serverside functions and serialization logic

func DefaultBindingCapabilities

func DefaultBindingCapabilities() *BindingCapabilities

func (*BindingCapabilities) WithIncarnationTags added in v4.13.0

func (bc *BindingCapabilities) WithIncarnationTags(value bool) *BindingCapabilities

Enable namespaces timestamps support

func (*BindingCapabilities) WithQrIdleTimeouts

func (bc *BindingCapabilities) WithQrIdleTimeouts(value bool) *BindingCapabilities

Enable Query results idle timeouts support

func (*BindingCapabilities) WithResultsWithShardIDs

func (bc *BindingCapabilities) WithResultsWithShardIDs(value bool) *BindingCapabilities

Enable shard IDs support

type Completion

type Completion func(err error)

type ConnectOptions

type ConnectOptions struct {
	Storage uint16
	Opts    uint16
}

func DefaultConnectOptions

func DefaultConnectOptions() *ConnectOptions

func (*ConnectOptions) AllowNamespaceErrors

func (so *ConnectOptions) AllowNamespaceErrors(value bool) *ConnectOptions

func (*ConnectOptions) OpenNamespaces

func (so *ConnectOptions) OpenNamespaces(value bool) *ConnectOptions

func (*ConnectOptions) StorageType

func (so *ConnectOptions) StorageType(value uint16) *ConnectOptions

Choose storage type

type Error

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

func (Error) Code

func (e Error) Code() int

func (Error) Error

func (e Error) Error() string

type Event added in v4.16.0

type Event struct {
	Type      int
	NSVersion LsnT
	LSN       LsnT
	ShardID   int
	ServerID  int
	Database  string
	Namespace string
	Timestamp time.Time
}

Events handler interface

type EventTypesMap added in v4.16.0

type EventTypesMap map[string]struct{}

func (EventTypesMap) MarshalJSON added in v4.16.0

func (em EventTypesMap) MarshalJSON() ([]byte, error)

func (EventTypesMap) UnmarshalJSON added in v4.16.0

func (em EventTypesMap) UnmarshalJSON(b []byte) error

type EventsHandler added in v4.16.0

type EventsHandler interface {
	OnEvent(RawBuffer) error
	OnError(error) error
}

type EventsNamespaceFilters added in v4.16.0

type EventsNamespaceFilters struct {
	Name string `json:"name"`
}

type EventsStreamOptions added in v4.16.0

type EventsStreamOptions struct {
	Namespaces          []EventsNamespaceFilters `json:"namespaces"`
	WithConfigNamespace bool                     `json:"with_config_namespace"`
	EventTypes          EventTypesMap            `json:"event_types"`
}

type EventsStreamOptionsByStream added in v4.16.0

type EventsStreamOptionsByStream struct {
	*EventsStreamOptions
	StreamID int `json:"id"`
}

type FetchMore

type FetchMore interface {
	Fetch(ctx context.Context, offset, limit int, asJson bool) (err error)
}

FetchMore interface for partial loading results (used in cproto/ucproto)

type FieldDef

type FieldDef struct {
	JSONPath string `json:"json_path"`
	Type     string `json:"type"`
	IsArray  bool   `json:"is_array"`
}

type GetReplicationStat

type GetReplicationStat interface {
	GetReplicationStat(f func(ctx context.Context) (*ReplicationStat, error))
}

type IndexDef

type IndexDef struct {
	Name        string      `json:"name"`
	JSONPaths   []string    `json:"json_paths"`
	IndexType   string      `json:"index_type"`
	FieldType   string      `json:"field_type"`
	IsPK        bool        `json:"is_pk"`
	IsArray     bool        `json:"is_array"`
	IsDense     bool        `json:"is_dense"`
	IsSparse    bool        `json:"is_sparse"`
	CollateMode string      `json:"collate_mode"`
	SortOrder   string      `json:"sort_order_letters"`
	ExpireAfter int         `json:"expire_after"`
	Config      interface{} `json:"config"`
	RTreeType   string      `json:"rtree_type"`
}

type LoadBalancingAlgorithm added in v4.11.0

type LoadBalancingAlgorithm int
const (
	LBRoundRobin LoadBalancingAlgorithm = iota
	LBRandom
	LBPowerOfTwoChoices
)

LBRoundRobin - choose connections in round-robin fashion. Used by default LBRandom - choose connections randomly LBPowerOfTwoChoices - choose connections using "Power of Two Choices" algorithm (https://www.nginx.com/blog/nginx-power-of-two-choices-load-balancing-algorithm/)

type Logger

type Logger interface {
	Printf(level int, fmt string, msg ...interface{})
}

Logger interface for reindexer

type LsnT added in v4.16.0

type LsnT struct {
	// Operation counter
	Counter int64 `json:"counter"`
	// Node identifier
	ServerId int `json:"server_id"`
}

Operation counter and server id

func CreateEmptyLSN added in v4.16.0

func CreateEmptyLSN() LsnT

func CreateLSNFromInt64 added in v4.16.0

func CreateLSNFromInt64(v int64) LsnT

func (*LsnT) IsCompatibleWith added in v4.16.0

func (lsn *LsnT) IsCompatibleWith(o LsnT) bool

func (*LsnT) IsEmpty added in v4.16.0

func (lsn *LsnT) IsEmpty() bool

func (*LsnT) IsNewerThen added in v4.16.0

func (lsn *LsnT) IsNewerThen(o LsnT) bool

type NamespaceDef

type NamespaceDef struct {
	Namespace   string      `json:"name"`
	StorageOpts StorageOpts `json:"storage"`
}

type NullLogger added in v4.13.0

type NullLogger struct {
}

func (NullLogger) Printf added in v4.13.0

func (NullLogger) Printf(level int, fmt string, msg ...interface{})

type OptionAppName

type OptionAppName struct {
	AppName string
}

AppName - Application name, which will be used in server connect info

type OptionBuiltinAllocatorConfig

type OptionBuiltinAllocatorConfig struct {
	AllocatorCacheLimit   int64
	AllocatorMaxCachePart float32
}

type OptionBuiltinMaxUpdatesSize added in v4.16.0

type OptionBuiltinMaxUpdatesSize struct {
	MaxUpdatesSizeBytes uint
}

MaxUpdatesSizeBytes for the internal replication/events queues

type OptionBuiltinWithServer

type OptionBuiltinWithServer struct {
	StartupTimeout  time.Duration
	ShutdownTimeout time.Duration
	ServerConfig    *config.ServerConfig
}

type OptionBuiltintCtxWatch

type OptionBuiltintCtxWatch struct {
	WatchDelay       time.Duration
	WatchersPoolSize int
}

OptionBuiltintCtxWatch - context watcher settings WatchDelay - minimal delay on context watcher goroutines launch. Timer resolution here is 20 ms WatchersPoolSize - watchers goroutine count (this doesn't affect goroutine count after WatchDelay expiration)

type OptionCgoLimit

type OptionCgoLimit struct {
	CgoLimit int
}

type OptionCompression

type OptionCompression struct {
	EnableCompression bool
}

OptionCompression - DB compression options for server EnableCompression - request compress traffic by snappy library

type OptionConnPoolLoadBalancing added in v4.11.0

type OptionConnPoolLoadBalancing struct {
	Algorithm LoadBalancingAlgorithm
}

OptionConnPoolLoadBalancing sets algorithm, which will be used to choose connection for cproto/ucproto requests' balancing

type OptionConnPoolSize

type OptionConnPoolSize struct {
	ConnPoolSize int
}

type OptionConnect

type OptionConnect struct {
	CreateDBIfMissing bool
}

OptionConnect - DB connect options for server CreateDBIfMissing - allow to create DB on connect if DB doesn't exist already

type OptionDedicatedThreads

type OptionDedicatedThreads struct {
	DedicatedThreads bool
}

OptionDedicatedThreads - dedicated RPC threads options for server DedicatedThreads - request dedicated thread on server side for each connection of this binding

type OptionOpenTelemetry added in v4.11.0

type OptionOpenTelemetry struct {
	EnableTracing bool
}

OptionOpenTelemetry - enables OpenTelemetry integration.

type OptionPrometheusMetrics added in v4.11.0

type OptionPrometheusMetrics struct {
	EnablePrometheusMetrics bool
}

OptionPrometheusMetrics - enables collection of Reindexer's client side metrics (for example, information about latency and rpc of all rx client calls like Upsert, Select, etc).

type OptionReconnectionStrategy

type OptionReconnectionStrategy struct {
	Strategy          string
	AllowUnknownNodes bool
}

Strategy - Strategy used for reconnect to server on connection error AllowUnknownNodes - Allow add dsn from cluster node, that not exist in original dsn list

type OptionReindexerInstance

type OptionReindexerInstance struct {
	Instance uintptr
}

type OptionRetryAttempts

type OptionRetryAttempts struct {
	Read  int
	Write int
}

type OptionStrictJoinHandlers added in v4.13.0

type OptionStrictJoinHandlers struct {
	EnableStrictJoinHandlers bool
}

OptionStrictJoinHandlers - enables join handlers check. If enabled, queries without required join handlers or Joinable interface will return error after execution.

type OptionTLS added in v4.19.0

type OptionTLS struct {
	Config *tls.Config
}

type OptionTimeouts

type OptionTimeouts struct {
	LoginTimeout   time.Duration
	RequestTimeout time.Duration
}

OptionTimeouts sets client-side network timeouts on login(connect) and requests Timer resolution here is 1 second

type RawBinding

type RawBinding interface {
	Init(u []url.URL, eh EventsHandler, options ...interface{}) error
	Clone() RawBinding
	OpenNamespace(ctx context.Context, namespace string, enableStorage, dropOnFileFormatError bool) error
	CloseNamespace(ctx context.Context, namespace string) error
	DropNamespace(ctx context.Context, namespace string) error
	TruncateNamespace(ctx context.Context, namespace string) error
	RenameNamespace(ctx context.Context, srcNs string, dstNs string) error
	AddIndex(ctx context.Context, namespace string, indexDef IndexDef) error
	SetSchema(ctx context.Context, namespace string, schema SchemaDef) error
	UpdateIndex(ctx context.Context, namespace string, indexDef IndexDef) error
	DropIndex(ctx context.Context, namespace, index string) error
	BeginTx(ctx context.Context, namespace string) (TxCtx, error)
	CommitTx(txCtx *TxCtx) (RawBuffer, error)
	RollbackTx(tx *TxCtx) error
	ModifyItemTx(txCtx *TxCtx, format int, data []byte, mode int, percepts []string, stateToken int) error
	ModifyItemTxAsync(txCtx *TxCtx, format int, data []byte, mode int, percepts []string, stateToken int, cmpl RawCompletion)
	DeleteQueryTx(txCtx *TxCtx, rawQuery []byte) error
	UpdateQueryTx(txCtx *TxCtx, rawQuery []byte) error

	EnumMeta(ctx context.Context, namespace string) ([]string, error)
	PutMeta(ctx context.Context, namespace, key, data string) error
	GetMeta(ctx context.Context, namespace, key string) (RawBuffer, error)
	DeleteMeta(ctx context.Context, namespace, key string) error
	ModifyItem(ctx context.Context, namespace string, format int, data []byte, mode int, percepts []string, stateToken int) (RawBuffer, error)
	Select(ctx context.Context, query string, asJson bool, ptVersions []int32, fetchCount int) (RawBuffer, error)
	SelectQuery(ctx context.Context, rawQuery []byte, asJson bool, ptVersions []int32, fetchCount int) (RawBuffer, error)
	DeleteQuery(ctx context.Context, rawQuery []byte) (RawBuffer, error)
	UpdateQuery(ctx context.Context, rawQuery []byte) (RawBuffer, error)
	EnableLogger(logger Logger)
	DisableLogger()
	GetLogger() Logger
	ReopenLogFiles() error
	Ping(ctx context.Context) error
	Finalize() error
	Status(ctx context.Context) Status
	GetDSNs() []url.URL
	Subscribe(ctx context.Context, opts *SubscriptionOptions) error
	Unsubscribe(ctx context.Context) error
}

Raw binding to reindexer

func GetBinding

func GetBinding(name string) RawBinding

type RawBindingChanging

type RawBindingChanging interface {
	OnChangeCallback(f func())
}

type RawBuffer

type RawBuffer interface {
	GetBuf() []byte
	Free()
}

go interface to reindexer_c.h interface

type RawCompletion

type RawCompletion func(buf RawBuffer, err error)

type ReplicationNodeStat

type ReplicationNodeStat struct {
	DSN            string `json:"dsn"`
	Status         string `json:"status"`
	Role           string `json:"role"`
	IsSynchronized bool   `json:"is_synchronized"`
}

type ReplicationStat

type ReplicationStat struct {
	Type  string                `json:"type"`
	Nodes []ReplicationNodeStat `json:"nodes"`
}

type SchemaDef

type SchemaDef jsonschema.Schema

type Stats

type Stats struct {
	CountGetItem int
	TimeGetItem  time.Duration
	CountSelect  int
	TimeSelect   time.Duration
	CountInsert  int
	TimeInsert   time.Duration
	CountUpdate  int
	TimeUpdate   time.Duration
	CountUpsert  int
	TimeUpsert   time.Duration
	CountDelete  int
	TimeDelete   time.Duration
	CountJoin    int
	TimeJoin     time.Duration
}

type Status

type Status struct {
	Err     error
	CProto  StatusCProto
	Builtin StatusBuiltin
	Cache   StatusCache
}

type StatusBuiltin

type StatusBuiltin struct {
	CGOLimit           int
	CGOUsage           int
	CGOUsageLastMinAvg int
}

type StatusCProto

type StatusCProto struct {
	ConnPoolSize   int
	ConnPoolUsage  int
	ConnQueueSize  int
	ConnQueueUsage int
	ConnAddr       string
}

type StatusCache

type StatusCache struct {
	CurSize int64
}

type StorageOptions

type StorageOptions uint16

func (*StorageOptions) DropOnFileFormatError

func (so *StorageOptions) DropOnFileFormatError(value bool) *StorageOptions

func (*StorageOptions) Enabled

func (so *StorageOptions) Enabled(value bool) *StorageOptions

type StorageOpts

type StorageOpts struct {
	EnableStorage     bool `json:"enabled"`
	DropOnFormatError bool `json:"drop_on_file_format_error"`
	CreateIfMissing   bool `json:"create_if_missing"`
}

type SubscriptionOptions added in v4.16.0

type SubscriptionOptions struct {
	Version          int                           `json:"version"`
	SubscriptionType int                           `json:"subscription_type"`
	Streams          []EventsStreamOptionsByStream `json:"streams"`
	WithDBName       bool                          `json:"with_db_name"`
	WithServerID     bool                          `json:"with_server_id"`
	WithShardID      bool                          `json:"with_shard_id"`
	WithLSN          bool                          `json:"with_lsn"`
	WithTimestamp    bool                          `json:"with_timestamp"`
	DataType         string                        `json:"data_type"`
}

type TxCtx

type TxCtx struct {
	Result  RawBuffer
	Id      uint64
	UserCtx context.Context
}

go transanction context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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