Documentation
¶
Index ¶
- Constants
- Variables
- func NextSyncSequenceValue() uint64
- func Skip(dec *msgpack.Decoder, num int) error
- type Auth
- type Call
- type Code
- type Connection
- func (c *Connection) Auth(ctx context.Context, user, password string) error
- func (c *Connection) Close() error
- func (c *Connection) Exec(ctx context.Context, query Query) error
- func (c *Connection) Indexes(ctx context.Context) (Indexes, error)
- func (c *Connection) Query(ctx context.Context, query Query, result msgpack.CustomDecoder) error
- func (c *Connection) Spaces(ctx context.Context) (Spaces, error)
- type Decoder
- type Delete
- type Driver
- type Error
- type ErrorCode
- type Exchange
- type Execute
- type Gate
- type GateState
- type Header
- type Index
- type Indexes
- type Insert
- type Iterator
- type Key
- type Operation
- func BitAndOperation(field, argument uint32) Operation
- func BitOrOperation(field, argument uint32) Operation
- func BitXorOperation(field, argument uint32) Operation
- func InsertOperation(beforeField uint32, argument any) Operation
- func RemoveOperation(field, num uint32) Operation
- func SetOperation(field uint32, argument any) Operation
- func SubOperation(field uint32, argument any) Operation
- func SumOperation(field uint32, argument any) Operation
- type Operations
- type Option
- type Options
- type Ping
- type Proto
- type Query
- type QueryError
- type Select
- type SingleResult
- type Space
- type Spaces
- type UUID
- type Update
- type Upsert
Constants ¶
const ( // Default size for the maximum number of requests sent at a time. DefaultSlotsSize = 255 // Default size of connection buffer. DefaultBufferSize = 4096 )
const ExtUUID msgpack.Ext = 2
ExtUUID is a code of UUID extension.
Variables ¶
var ( ErrUnexpectedGreeting = errors.New("unexpected tarantool server greeting message") ErrUnexpectedServerVersion = errors.New("unexpected tarantool server version") ErrNoConnectionSpecified = errors.New("no connection was specified") ErrInvalidSaltSize = errors.New("invalid salt size") ErrInvalidPackageSize = errors.New("invalid package size") ErrTooMachResults = errors.New("received too mach results") ErrGateInvalidState = errors.New("gate has invalid state") ErrNotFound = errors.New("was not found") ErrExchangeNotFound = errors.New("exchange was not found") ErrSpaceNotFound = errors.New("space was not found") ErrIndexNotFound = errors.New("index was not found") ErrConnectionClosed = errors.New("connection closed") ErrUnexpectedExtension = errors.New("unexpected extension code") )
Functions ¶
func NextSyncSequenceValue ¶
func NextSyncSequenceValue() uint64
NextSyncSequenceValue returns next unique sequence value.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth provides authentication Query.
func (*Auth) EncodeMsgpack ¶
EncodeMsgpack implements msgpack.CustomEncoder interface.
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call provides tarantool call/eval Query.
func (*Call) EncodeMsgpack ¶
EncodeMsgpack implements msgpack.CustomEncoder interface.
type Code ¶
type Code uint8
Code represents query type code.
const ( CodeOK Code = 0x00 // OK CodeSelect Code = 0x01 // Select CodeInsert Code = 0x02 // Insert CodeReplace Code = 0x03 // Replace CodeUpdate Code = 0x04 // Update CodeDelete Code = 0x05 // Delete CodeAuth Code = 0x07 // Auth CodeEval Code = 0x08 // Eval CodeUpsert Code = 0x09 // Upsert CodeCall Code = 0x0a // Call CodeExecute Code = 0x0b // Execute CodePrepare Code = 0x0d // Prepare CodePing Code = 0x40 // Ping )
func (*Code) DecodeMsgpack ¶
DecodeMsgpack implements msgpack.CustomDecoder interface.
func (Code) EncodeMsgpack ¶
EncodeMsgpack implements msgpack.CustomEncoder interface.
type Connection ¶
type Connection struct { ProtocolVersion string SessionID string // contains filtered or unexported fields }
Connection allows to establish connection and communicates with Tarantool server.
func NewConnection ¶
func NewConnection(conn net.Conn, options ...Option) (*Connection, error)
NewConnection returns a new instance of Connection.
func (*Connection) Auth ¶
func (c *Connection) Auth(ctx context.Context, user, password string) error
Auth authenticates user by password and reload available spaces and indexes.
func (*Connection) Exec ¶
func (c *Connection) Exec(ctx context.Context, query Query) error
Exec executes a query and do not returns result.
func (*Connection) Indexes ¶
func (c *Connection) Indexes(ctx context.Context) (Indexes, error)
Indexes returns a list of presented on a server indexes available to a user.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a structure for decoding response packet.
func NewDecoder ¶
NewDecoder returns a new instance of Decoder.
type Delete ¶
Delete provides delete tuple Query.
func (*Delete) EncodeMsgpack ¶
EncodeMsgpack implements msgpack.CustomEncoder interface.
type Driver ¶
type Driver interface { // Auth authenticates user by password and reload available spaces and indexes. Auth(ctx context.Context, user, password string) error // Spaces returns a list of presented on a server spaces available to a user. Spaces(ctx context.Context) (Spaces, error) // Indexes returns a list of presented on a server indexes available to a user. Indexes(ctx context.Context) (Indexes, error) // Exec executes a query and do not returns result. Exec(ctx context.Context, query Query) error // Query executes a query and decodes response to result. Query(ctx context.Context, query Query, result msgpack.CustomDecoder) error // Close closes connection. Close() error }
Driver is an interface for communicates with Tarantool Server.
type Error ¶
type Error struct { Type string File string Line uint32 Message string ErrNo uint16 ErrCode uint16 Fields map[string]any }
Error is a struct for error response from Tarantool Server.
func (*Error) DecodeMsgpack ¶
DecodeMsgpack implements msgpack.CustomDecoder interface.
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
func NewExchange ¶
NewExchange returns a new instance of Exchange.
type Execute ¶
type Execute struct {
// contains filtered or unexported fields
}
Execute defines Tarantool execute query.
func NewExecute ¶
NewExecute creates a new instance of Execute query.
func (*Execute) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Gate ¶
Gate links query and response.
type Header ¶
Header represents Tarantool binary protocol message header.
func (*Header) DecodeMsgpack ¶
DecodeMsgpack implements interface msgpack.CustomDecoder.
func (*Header) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Index ¶
Index defines Tarantool index object.
func GetIndex ¶
GetIndex finds an index by its name in specified space. Method returns ErrIndexNotFound if index was not found.
func (*Index) DecodeMsgpack ¶
DecodeMsgpack implements interface msgpack.CustomDecoder.
func (*Index) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Indexes ¶
type Indexes []Index
Indexes define a list of Index.
func (*Indexes) DecodeMsgpack ¶
DecodeMsgpack implements interface msgpack.CustomDecoder.
type Insert ¶
Insert defines Tarantool insert query.
func NewReplace ¶
NewReplace creates a new instance of Insert with replace flag.
func (*Insert) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Iterator ¶
type Iterator uint8
const ( IterateEqual Iterator = iota // key == x ASC order IterateReverseEqual // key == x DESC order IterateAll // all tuples IterateLessThan // key < x IterateLessThanOrEqual // key <= x IterateGreaterThan // key >= x IterateGreaterThanOrEqual // key > x IterateBitsAllSet // all bits from x are set in key IterateBitsAnySet // at least one x's bit is set IterateBitsAllNotSet // all bits are not set )
type Key ¶
type Key []any
Key defines query key.
func (Key) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation defines Tarantool operation.
func BitAndOperation ¶
func BitOrOperation ¶
func BitXorOperation ¶
func InsertOperation ¶
func RemoveOperation ¶
func SetOperation ¶
func SubOperation ¶
func SumOperation ¶
func (*Operation) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Operations ¶
type Operations []Operation
Operations supports fast encoding slice of Operation in msgpack format.
func (Operations) EncodeMsgpack ¶
func (o Operations) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack implements msgpack.CustomEncoder interface.
type Option ¶
type Option func(*Options)
Option defines interface for configure Options.
func BufferSize ¶
BufferSize creates Option allows to set read and write buffer sizes.
func ReadBufferSize ¶
ReadBufferSize creates Option allows to set read buffer size.
func WriteBufferSize ¶
WriteBufferSize creates Option allows to set write buffer size.
type Options ¶
type Options struct { // BufferSize allows to configure size of buffers. BufferSize struct { // Read defines a size of read buffer. Read int // Write defines a size of write buffer. Write int } // SlotsSize represents maximum number of slots. SlotsSize int }
Options defines full list of supported options.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions creates Options with default values.
type Ping ¶
type Ping struct{}
Ping defines Tarantool Ping query.
func (Ping) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Proto ¶
type Proto uint8
Proto defines reserved codes in tarantool binary protocol.
const ( ProtoCode Proto = 0x00 // Code ProtoSync Proto = 0x01 // Sync ProtoSchema Proto = 0x05 // Schema ProtoSpaceNo Proto = 0x10 // SpaceNo ProtoIndexNo Proto = 0x11 // IndexNo ProtoLimit Proto = 0x12 // Limit ProtoOffset Proto = 0x13 // Offset ProtoIterator Proto = 0x14 // Iterator ProtoKey Proto = 0x20 // Key ProtoTuple Proto = 0x21 // Tuple ProtoFunctionName Proto = 0x22 // FunctionName ProtoUserName Proto = 0x23 // UserName ProtoExpression Proto = 0x27 // Expression ProtoDefTuple Proto = 0x28 // DefTuple ProtoData Proto = 0x30 // Data ProtoError24 Proto = 0x31 // Error24 ProtoMetaData Proto = 0x32 // MetaData ProtoSQLBindMeta Proto = 0x33 // SQLBindMeta ProtoSQLBindCount Proto = 0x34 // SQLBindCount ProtoSQLText Proto = 0x40 // SQLText ProtoSQLBind Proto = 0x41 // SQLBind ProtoSQLInfo Proto = 0x42 // SQLInfo ProtoSQLStatement Proto = 0x43 // SQLStatement ProtoOptions Proto = 0x2b // Options ProtoError Proto = 0x52 // Error )
func (*Proto) DecodeMsgpack ¶
DecodeMsgpack implements interface msgpack.CustomDecoder.
func (Proto) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Query ¶
type Query interface { msgpack.CustomEncoder // Code returns Code of query. Code() Code }
Query defines interface for all types of tarantool queries.
type QueryError ¶
QueryError is a wrapper for failed Query.
func NewQueryError ¶
func NewQueryError(query Query, err error) *QueryError
NewQueryError creates a new instance of QueryError.
func (QueryError) Cause ¶
func (q QueryError) Cause() error
Cause is useful for unwrapping origin error.
func (QueryError) Unwrap ¶
func (q QueryError) Unwrap() error
Unwrap is useful for unwrapping origin error.
type Select ¶
type Select struct { Space *Space Index *Index Iterator Iterator Key Key Limit uint64 Offset uint64 }
Select defines Tarantool select query.
func (*Select) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type SingleResult ¶
type SingleResult struct {
// contains filtered or unexported fields
}
SingleResult helps to decode single response to Result.
func NewSingleResult ¶
func NewSingleResult(dec msgpack.CustomDecoder) *SingleResult
NewSingleResult returns a new instance of SingleResult.
func (*SingleResult) DecodeMsgpack ¶
func (s *SingleResult) DecodeMsgpack(dec *msgpack.Decoder) error
DecodeMsgpack implements interface msgpack.CustomDecoder.
type Space ¶
Space defines Tarantool space object.
func GetSpace ¶
GetSpace finds a space by its name. Method returns ErrSpaceNotFound if space was not found.
func (*Space) DecodeMsgpack ¶
DecodeMsgpack implements interface msgpack.CustomDecoder.
func (*Space) EncodeMsgpack ¶
EncodeMsgpack implements interface msgpack.CustomEncoder.
type Spaces ¶
type Spaces []Space
Spaces define a list of Space.
func (*Spaces) DecodeMsgpack ¶
DecodeMsgpack implements interface msgpack.CustomDecoder.
type UUID ¶
UUID represents wrapper for uuid.UUID with implemented msgpack.CustomDecoder and msgpack.CustomEncoder interfaces.
func (*UUID) DecodeMsgpack ¶
DecodeMsgpack implements msgpack.CustomDecoder interface.
func (UUID) EncodeMsgpack ¶
EncodeMsgpack implements msgpack.CustomEncoder interface.
type Update ¶
type Update struct { Space *Space Index *Index Key Key Operations Operations }
Update defines Tarantool update query.
func NewUpdate ¶
func NewUpdate(space *Space, index *Index, key Key, operations Operations) *Update
NewUpdate creates a new instance of Update.
func (*Update) EncodeMsgpack ¶
EncodeMsgpack implements interface Query.
type Upsert ¶
type Upsert struct { Space *Space Data any Operations Operations }
Upsert defines Tarantool upsert query.
func NewUpsert ¶
func NewUpsert(space *Space, data any, operations Operations) *Upsert
NewUpsert creates a new instance of Upsert.
func (*Upsert) EncodeMsgpack ¶
EncodeMsgpack implements interface Query.
Source Files
¶
- auth.go
- call.go
- code.go
- code_string.go
- connection.go
- const.go
- decoder.go
- delete.go
- driver.go
- error.go
- errors.go
- exchange.go
- execute.go
- gate.go
- gate_state.go
- gate_state_string.go
- header.go
- helpers.go
- index.go
- indexes.go
- insert.go
- iterator.go
- key.go
- operation.go
- operations.go
- options.go
- ping.go
- proto.go
- proto_string.go
- query.go
- select.go
- sequence.go
- space.go
- spaces.go
- update.go
- upsert.go
- uuid.go