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 Header
- type Index
- type Indexes
- type Insert
- type Iterator
- type Key
- type Operation
- func BitAndOperation(field, argument uint) Operation
- func BitOrOperation(field, argument uint) Operation
- func BitXorOperation(field, argument uint) Operation
- func InsertOperation(beforeField uint, argument interface{}) Operation
- func RemoveOperation(field, num uint) Operation
- func SetOperation(field uint, argument interface{}) Operation
- func SubOperation(field uint, argument interface{}) Operation
- func SumOperation(field uint, argument interface{}) 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.WithMessage(ErrNotFound, "exchange") ErrSpaceNotFound = errors.WithMessage(ErrNotFound, "space") ErrIndexNotFound = errors.WithMessage(ErrNotFound, "index") ErrConnectionClosed = errors.New("connection closed") ErrUnexpectedExtension = errors.New("unexpected extension code") )
Functions ¶
func NextSyncSequenceValue ¶ added in v1.2.0
func NextSyncSequenceValue() uint64
NextSyncSequenceValue returns next unique sequence value.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth provides authentication Query.
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call provides tarantool call/eval Query.
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.
func (*Connection) Query ¶
func (c *Connection) Query(ctx context.Context, query Query, result msgpack.CustomDecoder) error
Query executes a query and decodes response to result.
type Decoder ¶ added in v1.4.0
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a structure for decoding response packet.
func NewDecoder ¶ added in v1.4.0
NewDecoder returns a new instance of Decoder.
type Delete ¶
Delete provides delete tuple Query.
type Driver ¶ added in v1.4.0
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 ¶ added in v1.2.0
type Error struct { Type string File string Line uint Message string ErrNo uint ErrCode uint Fields map[string]interface{} }
Error is a struct for error response from Tarantool Server.
func (*Error) DecodeMsgpack ¶ added in v1.2.0
DecodeMsgpack implements msgpack.CustomDecoder interface.
type ErrorCode ¶ added in v1.2.0
type ErrorCode uint8
ErrorCode represents error codes from Tarantool Server.
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
func NewExchange ¶
NewExchange returns a new instance of Exchange.
type Execute ¶ added in v1.2.0
type Execute struct {
// contains filtered or unexported fields
}
Execute defines Tarantool execute query.
func NewExecute ¶ added in v1.2.0
NewExecute creates a new instance of Execute query.
type Gate ¶ added in v1.4.0
Gate links query and response.
func NewGate ¶ added in v1.4.0
func NewGate(code Code, result msgpack.CustomDecoder) (*Gate, error)
NewGate returns a new instance of Gate. Each Gate MUST be Free() after usage.
func (*Gate) Free ¶ added in v1.4.0
func (g *Gate) Free()
Free frees resources and returns Gate to pool. This gate can't be used after invoking this method.
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 ¶ added in v1.4.0
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.
type Indexes ¶
type Indexes []Index
Indexes define a list of Index.
type Insert ¶
Insert defines Tarantool insert query.
func NewReplace ¶
NewReplace creates a new instance of Insert with replace flag.
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 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 ¶
type Operations ¶ added in v1.2.0
type Operations []Operation
Operations supports fast encoding slice of Operation in msgpack format.
func (Operations) EncodeMsgpack ¶ added in v1.2.0
func (o Operations) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack implements msgpack.CustomEncoder interface.
type Option ¶ added in v1.3.0
type Option func(*Options)
Option defines interface for configure Options.
func BufferSize ¶ added in v1.3.0
BufferSize creates Option allows to set read and write buffer sizes.
func ReadBufferSize ¶ added in v1.3.0
ReadBufferSize creates Option allows to set read buffer size.
func WriteBufferSize ¶ added in v1.3.0
WriteBufferSize creates Option allows to set write buffer size.
type Options ¶ added in v1.3.0
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 ¶ added in v1.3.0
func DefaultOptions() Options
DefaultOptions creates Options with default values.
type Proto ¶ added in v1.3.0
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 ¶ added in v1.3.0
DecodeMsgpack implements interface msgpack.CustomDecoder.
func (Proto) EncodeMsgpack ¶ added in v1.3.0
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 ¶ added in v1.2.0
QueryError is a wrapper for failed Query.
func NewQueryError ¶ added in v1.2.0
func NewQueryError(query Query, err error) *QueryError
NewQueryError creates a new instance of QueryError.
func (QueryError) Cause ¶ added in v1.3.0
func (q QueryError) Cause() error
Cause is useful for unwrapping origin error.
func (QueryError) Error ¶ added in v1.2.0
func (q QueryError) Error() string
Error implements error interface.
func (QueryError) Unwrap ¶ added in v1.2.0
func (q QueryError) Unwrap() error
Unwrap is useful for unwrapping origin error.
type Select ¶
Select defines Tarantool select query.
type SingleResult ¶ added in v1.2.0
type SingleResult struct {
// contains filtered or unexported fields
}
SingleResult helps to decode single response to Result.
func NewSingleResult ¶ added in v1.2.0
func NewSingleResult(dec msgpack.CustomDecoder) *SingleResult
NewSingleResult returns a new instance of SingleResult.
func (*SingleResult) DecodeMsgpack ¶ added in v1.2.0
func (s *SingleResult) DecodeMsgpack(dec *msgpack.Decoder) error
DecodeMsgpack implements interface msgpack.CustomDecoder.
type Space ¶
Space defines Tarantool space object.
func GetSpace ¶ added in v1.4.0
GetSpace finds a space by its name. Method returns ErrSpaceNotFound if space was not found.
func (*Space) DecodeMsgpack ¶
DecodeMsgpack implements interface msgpack.CustomDecoder.
type Spaces ¶
type Spaces []Space
Spaces define a list of Space.
type UUID ¶ added in v1.5.2
UUID represents wrapper for uuid.UUID with implemented msgpack.CustomDecoder and msgpack.CustomEncoder interfaces.
func (*UUID) DecodeMsgpack ¶ added in v1.5.2
DecodeMsgpack implements msgpack.CustomDecoder interface.
type Update ¶
type Update struct { Space *Space Index *Index Key Key Operations Operations }
Update defines Tarantool update query.
type Upsert ¶
type Upsert struct { Space *Space Data interface{} Operations Operations }
Upsert defines Tarantool upsert query.
func NewUpsert ¶
func NewUpsert(space *Space, data interface{}, operations Operations) *Upsert
NewUpsert creates a new instance of Upsert.
Source Files
¶
- auth.go
- call.go
- code.go
- code_string.go
- connection.go
- decoder.go
- delete.go
- driver.go
- error.go
- errors.go
- exchange.go
- execute.go
- gate.go
- gate_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