Documentation
¶
Overview ¶
Package crud with support of API of Tarantool's CRUD module.
Supported CRUD methods:
insert
insert_object
insert_many
insert_object_many
get
update
delete
replace
replace_object
replace_many
replace_object_many
upsert
upsert_object
upsert_many
upsert_object_many
select
min
max
truncate
len
storage_info
count
stats
unflatten_rows
Since: 1.11.0.
Index ¶
- type BaseOpts
- type BoolResult
- type BorderOpts
- type Condition
- type CountOpts
- type CountRequest
- func (req CountRequest) Async() bool
- func (req CountRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req CountRequest) Conditions(conditions []Condition) CountRequest
- func (req CountRequest) Context(ctx context.Context) CountRequest
- func (req CountRequest) Ctx() context.Context
- func (req CountRequest) Opts(opts CountOpts) CountRequest
- func (req CountRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req CountRequest) Type() iproto.Type
- type CountResult
- type DeleteOpts
- type DeleteRequest
- func (req DeleteRequest) Async() bool
- func (req DeleteRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req DeleteRequest) Context(ctx context.Context) DeleteRequest
- func (req DeleteRequest) Ctx() context.Context
- func (req DeleteRequest) Key(key Tuple) DeleteRequest
- func (req DeleteRequest) Opts(opts DeleteOpts) DeleteRequest
- func (req DeleteRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req DeleteRequest) Type() iproto.Type
- type Error
- type ErrorMany
- type FieldFormat
- type GetOpts
- type GetRequest
- func (req GetRequest) Async() bool
- func (req GetRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req GetRequest) Context(ctx context.Context) GetRequest
- func (req GetRequest) Ctx() context.Context
- func (req GetRequest) Key(key Tuple) GetRequest
- func (req GetRequest) Opts(opts GetOpts) GetRequest
- func (req GetRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req GetRequest) Type() iproto.Type
- type Index
- type IndexPart
- type InsertManyOpts
- type InsertManyRequest
- func (req InsertManyRequest) Async() bool
- func (req InsertManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req InsertManyRequest) Context(ctx context.Context) InsertManyRequest
- func (req InsertManyRequest) Ctx() context.Context
- func (req InsertManyRequest) Opts(opts InsertManyOpts) InsertManyRequest
- func (req InsertManyRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req InsertManyRequest) Tuples(tuples Tuples) InsertManyRequest
- func (req InsertManyRequest) Type() iproto.Type
- type InsertObjectManyOpts
- type InsertObjectManyRequest
- func (req InsertObjectManyRequest) Async() bool
- func (req InsertObjectManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req InsertObjectManyRequest) Context(ctx context.Context) InsertObjectManyRequest
- func (req InsertObjectManyRequest) Ctx() context.Context
- func (req InsertObjectManyRequest) Objects(objects Objects) InsertObjectManyRequest
- func (req InsertObjectManyRequest) Opts(opts InsertObjectManyOpts) InsertObjectManyRequest
- func (req InsertObjectManyRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req InsertObjectManyRequest) Type() iproto.Type
- type InsertObjectOpts
- type InsertObjectRequest
- func (req InsertObjectRequest) Async() bool
- func (req InsertObjectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req InsertObjectRequest) Context(ctx context.Context) InsertObjectRequest
- func (req InsertObjectRequest) Ctx() context.Context
- func (req InsertObjectRequest) Object(object Object) InsertObjectRequest
- func (req InsertObjectRequest) Opts(opts InsertObjectOpts) InsertObjectRequest
- func (req InsertObjectRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req InsertObjectRequest) Type() iproto.Type
- type InsertOpts
- type InsertRequest
- func (req InsertRequest) Async() bool
- func (req InsertRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req InsertRequest) Context(ctx context.Context) InsertRequest
- func (req InsertRequest) Ctx() context.Context
- func (req InsertRequest) Opts(opts InsertOpts) InsertRequest
- func (req InsertRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req InsertRequest) Tuple(tuple Tuple) InsertRequest
- func (req InsertRequest) Type() iproto.Type
- type LenOpts
- type LenRequest
- func (req LenRequest) Async() bool
- func (req LenRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req LenRequest) Context(ctx context.Context) LenRequest
- func (req LenRequest) Ctx() context.Context
- func (req LenRequest) Opts(opts LenOpts) LenRequest
- func (req LenRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req LenRequest) Type() iproto.Type
- type LenResult
- type MapObject
- type MaxOpts
- type MaxRequest
- func (req MaxRequest) Async() bool
- func (req MaxRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req MaxRequest) Context(ctx context.Context) MaxRequest
- func (req MaxRequest) Ctx() context.Context
- func (req MaxRequest) Index(index any) MaxRequest
- func (req MaxRequest) Opts(opts MaxOpts) MaxRequest
- func (req MaxRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req MaxRequest) Type() iproto.Type
- type MinOpts
- type MinRequest
- func (req MinRequest) Async() bool
- func (req MinRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req MinRequest) Context(ctx context.Context) MinRequest
- func (req MinRequest) Ctx() context.Context
- func (req MinRequest) Index(index any) MinRequest
- func (req MinRequest) Opts(opts MinOpts) MinRequest
- func (req MinRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req MinRequest) Type() iproto.Type
- type NumberResult
- type Object
- type ObjectOperationsData
- type Objects
- type Operation
- type OperationManyOpts
- type OperationObjectManyOpts
- type Operator
- type ReplaceManyOpts
- type ReplaceManyRequest
- func (req ReplaceManyRequest) Async() bool
- func (req ReplaceManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req ReplaceManyRequest) Context(ctx context.Context) ReplaceManyRequest
- func (req ReplaceManyRequest) Ctx() context.Context
- func (req ReplaceManyRequest) Opts(opts ReplaceManyOpts) ReplaceManyRequest
- func (req ReplaceManyRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req ReplaceManyRequest) Tuples(tuples Tuples) ReplaceManyRequest
- func (req ReplaceManyRequest) Type() iproto.Type
- type ReplaceObjectManyOpts
- type ReplaceObjectManyRequest
- func (req ReplaceObjectManyRequest) Async() bool
- func (req ReplaceObjectManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req ReplaceObjectManyRequest) Context(ctx context.Context) ReplaceObjectManyRequest
- func (req ReplaceObjectManyRequest) Ctx() context.Context
- func (req ReplaceObjectManyRequest) Objects(objects Objects) ReplaceObjectManyRequest
- func (req ReplaceObjectManyRequest) Opts(opts ReplaceObjectManyOpts) ReplaceObjectManyRequest
- func (req ReplaceObjectManyRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req ReplaceObjectManyRequest) Type() iproto.Type
- type ReplaceObjectOpts
- type ReplaceObjectRequest
- func (req ReplaceObjectRequest) Async() bool
- func (req ReplaceObjectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req ReplaceObjectRequest) Context(ctx context.Context) ReplaceObjectRequest
- func (req ReplaceObjectRequest) Ctx() context.Context
- func (req ReplaceObjectRequest) Object(object Object) ReplaceObjectRequest
- func (req ReplaceObjectRequest) Opts(opts ReplaceObjectOpts) ReplaceObjectRequest
- func (req ReplaceObjectRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req ReplaceObjectRequest) Type() iproto.Type
- type ReplaceOpts
- type ReplaceRequest
- func (req ReplaceRequest) Async() bool
- func (req ReplaceRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req ReplaceRequest) Context(ctx context.Context) ReplaceRequest
- func (req ReplaceRequest) Ctx() context.Context
- func (req ReplaceRequest) Opts(opts ReplaceOpts) ReplaceRequest
- func (req ReplaceRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req ReplaceRequest) Tuple(tuple Tuple) ReplaceRequest
- func (req ReplaceRequest) Type() iproto.Type
- type Result
- type Schema
- type SchemaOpts
- type SchemaRequest
- func (req SchemaRequest) Async() bool
- func (req SchemaRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req SchemaRequest) Context(ctx context.Context) SchemaRequest
- func (req SchemaRequest) Ctx() context.Context
- func (req SchemaRequest) Opts(opts SchemaOpts) SchemaRequest
- func (req SchemaRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req SchemaRequest) Space(space string) SchemaRequest
- func (req SchemaRequest) Type() iproto.Type
- type SchemaResult
- type SelectOpts
- type SelectRequest
- func (req SelectRequest) Async() bool
- func (req SelectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req SelectRequest) Conditions(conditions []Condition) SelectRequest
- func (req SelectRequest) Context(ctx context.Context) SelectRequest
- func (req SelectRequest) Ctx() context.Context
- func (req SelectRequest) Opts(opts SelectOpts) SelectRequest
- func (req SelectRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req SelectRequest) Type() iproto.Type
- type SimpleOperationObjectOpts
- type SimpleOperationOpts
- type SpaceSchema
- type SpaceSchemaResult
- type StatsRequest
- func (req StatsRequest) Async() bool
- func (req StatsRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req StatsRequest) Context(ctx context.Context) StatsRequest
- func (req StatsRequest) Ctx() context.Context
- func (req StatsRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req StatsRequest) Space(space string) StatsRequest
- func (req StatsRequest) Type() iproto.Type
- type StatusTable
- type StorageInfoOpts
- type StorageInfoRequest
- func (req StorageInfoRequest) Async() bool
- func (req StorageInfoRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req StorageInfoRequest) Context(ctx context.Context) StorageInfoRequest
- func (req StorageInfoRequest) Ctx() context.Context
- func (req StorageInfoRequest) Opts(opts StorageInfoOpts) StorageInfoRequest
- func (req StorageInfoRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req StorageInfoRequest) Type() iproto.Type
- type StorageInfoResult
- type TruncateOpts
- type TruncateRequest
- func (req TruncateRequest) Async() bool
- func (req TruncateRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req TruncateRequest) Context(ctx context.Context) TruncateRequest
- func (req TruncateRequest) Ctx() context.Context
- func (req TruncateRequest) Opts(opts TruncateOpts) TruncateRequest
- func (req TruncateRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req TruncateRequest) Type() iproto.Type
- type TruncateResult
- type Tuple
- type TupleOperationsData
- type Tuples
- type UpdateOpts
- type UpdateRequest
- func (req UpdateRequest) Async() bool
- func (req UpdateRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req UpdateRequest) Context(ctx context.Context) UpdateRequest
- func (req UpdateRequest) Ctx() context.Context
- func (req UpdateRequest) Key(key Tuple) UpdateRequest
- func (req UpdateRequest) Operations(operations []Operation) UpdateRequest
- func (req UpdateRequest) Opts(opts UpdateOpts) UpdateRequest
- func (req UpdateRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req UpdateRequest) Type() iproto.Type
- type UpsertManyOpts
- type UpsertManyRequest
- func (req UpsertManyRequest) Async() bool
- func (req UpsertManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req UpsertManyRequest) Context(ctx context.Context) UpsertManyRequest
- func (req UpsertManyRequest) Ctx() context.Context
- func (req UpsertManyRequest) Opts(opts UpsertManyOpts) UpsertManyRequest
- func (req UpsertManyRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req UpsertManyRequest) TuplesOperationsData(tuplesOperationData []TupleOperationsData) UpsertManyRequest
- func (req UpsertManyRequest) Type() iproto.Type
- type UpsertObjectManyOpts
- type UpsertObjectManyRequest
- func (req UpsertObjectManyRequest) Async() bool
- func (req UpsertObjectManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req UpsertObjectManyRequest) Context(ctx context.Context) UpsertObjectManyRequest
- func (req UpsertObjectManyRequest) Ctx() context.Context
- func (req UpsertObjectManyRequest) ObjectsOperationsData(objectsOperationData []ObjectOperationsData) UpsertObjectManyRequest
- func (req UpsertObjectManyRequest) Opts(opts UpsertObjectManyOpts) UpsertObjectManyRequest
- func (req UpsertObjectManyRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req UpsertObjectManyRequest) Type() iproto.Type
- type UpsertObjectOpts
- type UpsertObjectRequest
- func (req UpsertObjectRequest) Async() bool
- func (req UpsertObjectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req UpsertObjectRequest) Context(ctx context.Context) UpsertObjectRequest
- func (req UpsertObjectRequest) Ctx() context.Context
- func (req UpsertObjectRequest) Object(object Object) UpsertObjectRequest
- func (req UpsertObjectRequest) Operations(operations []Operation) UpsertObjectRequest
- func (req UpsertObjectRequest) Opts(opts UpsertObjectOpts) UpsertObjectRequest
- func (req UpsertObjectRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req UpsertObjectRequest) Type() iproto.Type
- type UpsertOpts
- type UpsertRequest
- func (req UpsertRequest) Async() bool
- func (req UpsertRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
- func (req UpsertRequest) Context(ctx context.Context) UpsertRequest
- func (req UpsertRequest) Ctx() context.Context
- func (req UpsertRequest) Operations(operations []Operation) UpsertRequest
- func (req UpsertRequest) Opts(opts UpsertOpts) UpsertRequest
- func (req UpsertRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req UpsertRequest) Tuple(tuple Tuple) UpsertRequest
- func (req UpsertRequest) Type() iproto.Type
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseOpts ¶
type BaseOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
}
BaseOpts describes base options for CRUD operations.
type BoolResult ¶
type BoolResult struct {
Value bool
}
BoolResult describes CRUD result as an object containing bool.
func (*BoolResult) DecodeMsgpack ¶
func (r *BoolResult) DecodeMsgpack(d *msgpack.Decoder) error
DecodeMsgpack provides custom msgpack decoder.
type BorderOpts ¶
type BorderOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Fields is field names for getting only a subset of fields.
Fields option.Any
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata option.Bool
}
BorderOpts describes options for `crud.min` and `crud.max`.
func (BorderOpts) EncodeMsgpack ¶
func (opts BorderOpts) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack provides custom msgpack encoder.
type Condition ¶
type Condition struct {
Operator Operator
Field string // Field name or index name.
Value any
// contains filtered or unexported fields
}
Condition describes CRUD condition as a table {operator, field-identifier, value}.
type CountOpts ¶
type CountOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Mode is a parameter with `write`/`read` possible values,
// if `write` is specified then operation is performed on master.
Mode option.String
// PreferReplica is a parameter to specify preferred target
// as one of the replicas.
PreferReplica option.Bool
// Balance is a parameter to use replica according to vshard
// load balancing policy.
Balance option.Bool
// YieldEvery describes number of tuples processed to yield after.
// Should be positive.
YieldEvery option.Uint
// BucketId is a bucket ID.
BucketId option.Uint
// ForceMapCall describes the map call is performed without any
// optimizations even if full primary key equal condition is specified.
ForceMapCall option.Bool
// Fullscan describes if a critical log entry will be skipped on
// potentially long count.
Fullscan option.Bool
}
CountOpts describes options for `crud.count` method.
type CountRequest ¶
type CountRequest struct {
// contains filtered or unexported fields
}
CountRequest helps you to create request object to call `crud.count` for execution by a Connection.
func NewCountRequest ¶
func NewCountRequest(space string) CountRequest
NewCountRequest returns a new empty CountRequest.
func (CountRequest) Async ¶
func (req CountRequest) Async() bool
Async returns is CRUD request expects a response.
func (CountRequest) Body ¶
func (req CountRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (CountRequest) Conditions ¶
func (req CountRequest) Conditions(conditions []Condition) CountRequest
Conditions sets the conditions for the CountRequest request. Note: default value is nil.
func (CountRequest) Context ¶
func (req CountRequest) Context(ctx context.Context) CountRequest
Context sets a passed context to CRUD request.
func (CountRequest) Opts ¶
func (req CountRequest) Opts(opts CountOpts) CountRequest
Opts sets the options for the CountRequest request. Note: default value is nil.
type CountResult ¶
type CountResult = NumberResult
CountResult describes result for `crud.count` method.
type DeleteOpts ¶
type DeleteOpts = SimpleOperationOpts
DeleteOpts describes options for `crud.delete` method.
type DeleteRequest ¶
type DeleteRequest struct {
// contains filtered or unexported fields
}
DeleteRequest helps you to create request object to call `crud.delete` for execution by a Connection.
func NewDeleteRequest ¶
func NewDeleteRequest(space string) DeleteRequest
NewDeleteRequest returns a new empty DeleteRequest.
func (DeleteRequest) Async ¶
func (req DeleteRequest) Async() bool
Async returns is CRUD request expects a response.
func (DeleteRequest) Body ¶
func (req DeleteRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (DeleteRequest) Context ¶
func (req DeleteRequest) Context(ctx context.Context) DeleteRequest
Context sets a passed context to CRUD request.
func (DeleteRequest) Key ¶
func (req DeleteRequest) Key(key Tuple) DeleteRequest
Key sets the key for the DeleteRequest request. Note: default value is nil.
func (DeleteRequest) Opts ¶
func (req DeleteRequest) Opts(opts DeleteOpts) DeleteRequest
Opts sets the options for the DeleteRequest request. Note: default value is nil.
type Error ¶
type Error struct {
// ClassName is an error class that implies its source (for example, "CountError").
ClassName string
// Err is the text of reason.
Err string
// File is a source code file where the error was caught.
File string
// Line is a number of line in the source code file where the error was caught.
Line uint64
// Stack is an information about the call stack when an error
// occurs in a string format.
Stack string
// Str is the text of reason with error class.
Str string
// OperationData is the object/tuple with which an error occurred.
OperationData any
// contains filtered or unexported fields
}
Error describes CRUD error object.
func (*Error) DecodeMsgpack ¶
DecodeMsgpack provides custom msgpack decoder.
type ErrorMany ¶
type ErrorMany struct {
Errors []Error
// contains filtered or unexported fields
}
ErrorMany describes CRUD error object for `_many` methods.
func (*ErrorMany) DecodeMsgpack ¶
DecodeMsgpack provides custom msgpack decoder.
type FieldFormat ¶
FieldFormat contains field definition: {name='...',type='...'[,is_nullable=...]}.
func (*FieldFormat) DecodeMsgpack ¶
func (format *FieldFormat) DecodeMsgpack(d *msgpack.Decoder) error
DecodeMsgpack provides custom msgpack decoder.
type GetOpts ¶
type GetOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Fields is field names for getting only a subset of fields.
Fields option.Any
// BucketId is a bucket ID.
BucketId option.Uint
// Mode is a parameter with `write`/`read` possible values,
// if `write` is specified then operation is performed on master.
Mode option.String
// PreferReplica is a parameter to specify preferred target
// as one of the replicas.
PreferReplica option.Bool
// Balance is a parameter to use replica according to vshard
// load balancing policy.
Balance option.Bool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata option.Bool
}
GetOpts describes options for `crud.get` method.
type GetRequest ¶
type GetRequest struct {
// contains filtered or unexported fields
}
GetRequest helps you to create request object to call `crud.get` for execution by a Connection.
func NewGetRequest ¶
func NewGetRequest(space string) GetRequest
NewGetRequest returns a new empty GetRequest.
func (GetRequest) Async ¶
func (req GetRequest) Async() bool
Async returns is CRUD request expects a response.
func (GetRequest) Body ¶
func (req GetRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (GetRequest) Context ¶
func (req GetRequest) Context(ctx context.Context) GetRequest
Context sets a passed context to CRUD request.
func (GetRequest) Key ¶
func (req GetRequest) Key(key Tuple) GetRequest
Key sets the key for the GetRequest request. Note: default value is nil.
func (GetRequest) Opts ¶
func (req GetRequest) Opts(opts GetOpts) GetRequest
Opts sets the options for the GetRequest request. Note: default value is nil.
type Index ¶
type Index struct {
Id uint32 `msgpack:"id"`
Name string `msgpack:"name"`
Type string `msgpack:"type"`
Unique bool `msgpack:"unique"`
Parts []IndexPart `msgpack:"parts"`
}
Index contains a CRUD space index definition.
type IndexPart ¶
type IndexPart struct {
Fieldno uint32 `msgpack:"fieldno"`
Type string `msgpack:"type"`
ExcludeNull bool `msgpack:"exclude_null"`
IsNullable bool `msgpack:"is_nullable"`
}
IndexPart contains a CRUD space index part definition.
type InsertManyOpts ¶
type InsertManyOpts = OperationManyOpts
InsertManyOpts describes options for `crud.insert_many` method.
type InsertManyRequest ¶
type InsertManyRequest struct {
// contains filtered or unexported fields
}
InsertManyRequest helps you to create request object to call `crud.insert_many` for execution by a Connection.
func NewInsertManyRequest ¶
func NewInsertManyRequest(space string) InsertManyRequest
NewInsertManyRequest returns a new empty InsertManyRequest.
func (InsertManyRequest) Async ¶
func (req InsertManyRequest) Async() bool
Async returns is CRUD request expects a response.
func (InsertManyRequest) Body ¶
func (req InsertManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (InsertManyRequest) Context ¶
func (req InsertManyRequest) Context(ctx context.Context) InsertManyRequest
Context sets a passed context to CRUD request.
func (InsertManyRequest) Opts ¶
func (req InsertManyRequest) Opts(opts InsertManyOpts) InsertManyRequest
Opts sets the options for the InsertManyRequest request. Note: default value is nil.
func (InsertManyRequest) Response ¶
func (req InsertManyRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (InsertManyRequest) Tuples ¶
func (req InsertManyRequest) Tuples(tuples Tuples) InsertManyRequest
Tuples sets the tuples for the InsertManyRequest request. Note: default value is nil.
type InsertObjectManyOpts ¶
type InsertObjectManyOpts = OperationObjectManyOpts
InsertObjectManyOpts describes options for `crud.insert_object_many` method.
type InsertObjectManyRequest ¶
type InsertObjectManyRequest struct {
// contains filtered or unexported fields
}
InsertObjectManyRequest helps you to create request object to call `crud.insert_object_many` for execution by a Connection.
func NewInsertObjectManyRequest ¶
func NewInsertObjectManyRequest(space string) InsertObjectManyRequest
NewInsertObjectManyRequest returns a new empty InsertObjectManyRequest.
func (InsertObjectManyRequest) Async ¶
func (req InsertObjectManyRequest) Async() bool
Async returns is CRUD request expects a response.
func (InsertObjectManyRequest) Body ¶
func (req InsertObjectManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (InsertObjectManyRequest) Context ¶
func (req InsertObjectManyRequest) Context(ctx context.Context) InsertObjectManyRequest
Context sets a passed context to CRUD request.
func (InsertObjectManyRequest) Objects ¶
func (req InsertObjectManyRequest) Objects(objects Objects) InsertObjectManyRequest
Objects sets the objects for the InsertObjectManyRequest request. Note: default value is nil.
func (InsertObjectManyRequest) Opts ¶
func (req InsertObjectManyRequest) Opts(opts InsertObjectManyOpts) InsertObjectManyRequest
Opts sets the options for the InsertObjectManyRequest request. Note: default value is nil.
type InsertObjectOpts ¶
type InsertObjectOpts = SimpleOperationObjectOpts
InsertObjectOpts describes options for `crud.insert_object` method.
type InsertObjectRequest ¶
type InsertObjectRequest struct {
// contains filtered or unexported fields
}
InsertObjectRequest helps you to create request object to call `crud.insert_object` for execution by a Connection.
func NewInsertObjectRequest ¶
func NewInsertObjectRequest(space string) InsertObjectRequest
NewInsertObjectRequest returns a new empty InsertObjectRequest.
func (InsertObjectRequest) Async ¶
func (req InsertObjectRequest) Async() bool
Async returns is CRUD request expects a response.
func (InsertObjectRequest) Body ¶
func (req InsertObjectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (InsertObjectRequest) Context ¶
func (req InsertObjectRequest) Context(ctx context.Context) InsertObjectRequest
Context sets a passed context to CRUD request.
func (InsertObjectRequest) Object ¶
func (req InsertObjectRequest) Object(object Object) InsertObjectRequest
Object sets the tuple for the InsertObjectRequest request. Note: default value is nil.
func (InsertObjectRequest) Opts ¶
func (req InsertObjectRequest) Opts(opts InsertObjectOpts) InsertObjectRequest
Opts sets the options for the InsertObjectRequest request. Note: default value is nil.
type InsertOpts ¶
type InsertOpts = SimpleOperationOpts
InsertOpts describes options for `crud.insert` method.
type InsertRequest ¶
type InsertRequest struct {
// contains filtered or unexported fields
}
InsertRequest helps you to create request object to call `crud.insert` for execution by a Connection.
func NewInsertRequest ¶
func NewInsertRequest(space string) InsertRequest
NewInsertRequest returns a new empty InsertRequest.
func (InsertRequest) Async ¶
func (req InsertRequest) Async() bool
Async returns is CRUD request expects a response.
func (InsertRequest) Body ¶
func (req InsertRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (InsertRequest) Context ¶
func (req InsertRequest) Context(ctx context.Context) InsertRequest
Context sets a passed context to CRUD request.
func (InsertRequest) Opts ¶
func (req InsertRequest) Opts(opts InsertOpts) InsertRequest
Opts sets the options for the insert request. Note: default value is nil.
func (InsertRequest) Response ¶
func (req InsertRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (InsertRequest) Tuple ¶
func (req InsertRequest) Tuple(tuple Tuple) InsertRequest
Tuple sets the tuple for the InsertRequest request. Note: default value is nil.
type LenRequest ¶
type LenRequest struct {
// contains filtered or unexported fields
}
LenRequest helps you to create request object to call `crud.len` for execution by a Connection.
func NewLenRequest ¶
func NewLenRequest(space string) LenRequest
NewLenRequest returns a new empty LenRequest.
func (LenRequest) Async ¶
func (req LenRequest) Async() bool
Async returns is CRUD request expects a response.
func (LenRequest) Body ¶
func (req LenRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (LenRequest) Context ¶
func (req LenRequest) Context(ctx context.Context) LenRequest
Context sets a passed context to CRUD request.
func (LenRequest) Opts ¶
func (req LenRequest) Opts(opts LenOpts) LenRequest
Opts sets the options for the LenRequest request. Note: default value is nil.
type MapObject ¶
MapObject is a type to describe object as a map.
func UnflattenRows ¶
UnflattenRows can be used to convert received tuples to objects.
func (MapObject) EncodeMsgpack ¶
type MaxRequest ¶
type MaxRequest struct {
// contains filtered or unexported fields
}
MaxRequest helps you to create request object to call `crud.max` for execution by a Connection.
func NewMaxRequest ¶
func NewMaxRequest(space string) MaxRequest
NewMaxRequest returns a new empty MaxRequest.
func (MaxRequest) Async ¶
func (req MaxRequest) Async() bool
Async returns is CRUD request expects a response.
func (MaxRequest) Body ¶
func (req MaxRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (MaxRequest) Context ¶
func (req MaxRequest) Context(ctx context.Context) MaxRequest
Context sets a passed context to CRUD request.
func (MaxRequest) Index ¶
func (req MaxRequest) Index(index any) MaxRequest
Index sets the index name/id for the MaxRequest request. Note: default value is nil.
func (MaxRequest) Opts ¶
func (req MaxRequest) Opts(opts MaxOpts) MaxRequest
Opts sets the options for the MaxRequest request. Note: default value is nil.
type MinRequest ¶
type MinRequest struct {
// contains filtered or unexported fields
}
MinRequest helps you to create request object to call `crud.min` for execution by a Connection.
func NewMinRequest ¶
func NewMinRequest(space string) MinRequest
NewMinRequest returns a new empty MinRequest.
func (MinRequest) Async ¶
func (req MinRequest) Async() bool
Async returns is CRUD request expects a response.
func (MinRequest) Body ¶
func (req MinRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (MinRequest) Context ¶
func (req MinRequest) Context(ctx context.Context) MinRequest
Context sets a passed context to CRUD request.
func (MinRequest) Index ¶
func (req MinRequest) Index(index any) MinRequest
Index sets the index name/id for the MinRequest request. Note: default value is nil.
func (MinRequest) Opts ¶
func (req MinRequest) Opts(opts MinOpts) MinRequest
Opts sets the options for the MinRequest request. Note: default value is nil.
type NumberResult ¶
type NumberResult struct {
Value uint64
}
NumberResult describes CRUD result as an object containing number.
func (*NumberResult) DecodeMsgpack ¶
func (r *NumberResult) DecodeMsgpack(d *msgpack.Decoder) error
DecodeMsgpack provides custom msgpack decoder.
type Object ¶
type Object = any
Object is an interface to describe object for CRUD methods. It can be any type that msgpack can encode as a map.
type ObjectOperationsData ¶
type ObjectOperationsData struct {
Object Object
Operations []Operation
// contains filtered or unexported fields
}
ObjectOperationsData contains object with operations to be applied to object.
type Objects ¶
type Objects = any
Objects is a type to describe an array of object for CRUD methods. It can be any type that msgpack can encode, but encoded data must be an array of objects.
See the reason why not just []Object: https://github.com/tarantool/go-tarantool/issues/365
Example (CustomType) ¶
ExampleObjects_customType demonstrates how to use a slice of objects of a custom type as Objects to make a ReplaceObjectManyRequest.
package main
import (
"context"
"fmt"
"reflect"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
// The type will be encoded/decoded as a map.
type Tuple struct {
Id uint64 `msgpack:"id,omitempty"`
BucketId *uint64 `msgpack:"bucket_id,omitempty"`
Name string `msgpack:"name,omitempty"`
}
req := crud.NewReplaceObjectManyRequest(exampleSpace).Objects([]Tuple{
Tuple{
Id: 2010,
BucketId: nil,
Name: "bla",
},
})
ret := crud.NewResult(reflect.TypeFor[Tuple]())
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
fmt.Println(ret.Metadata)
rows := ret.Rows.([]Tuple)
if len(rows) == 1 {
fmt.Println(rows[0].Id)
fmt.Println(*rows[0].BucketId)
fmt.Println(rows[0].Name)
} else {
fmt.Printf("Unexpected result tuples count: %d", len(rows))
}
}
Output: [{id unsigned false} {bucket_id unsigned true} {name string false}] 2010 45 bla
type Operation ¶
type Operation struct {
Operator Operator
Field any // Number or string.
Value any
// Pos, Len, Replace fields used in the Splice operation.
Pos int
Len int
Replace string
}
Operation describes CRUD operation as a table {operator, field_identifier, value}. Splice operation described as a table {operator, field_identifier, position, length, replace_string}.
type OperationManyOpts ¶
type OperationManyOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Fields is field names for getting only a subset of fields.
Fields option.Any
// StopOnError is a parameter to stop on a first error and report
// error regarding the failed operation and error about what tuples
// were not performed.
StopOnError option.Bool
// RollbackOnError is a parameter because of what any failed operation
// will lead to rollback on a storage, where the operation is failed.
RollbackOnError option.Bool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata option.Bool
// Noreturn suppresses successfully processed data (first return value is `nil`).
// Disabled by default.
Noreturn option.Bool
}
OperationManyOpts describes options for CRUD operations with many tuples. It also covers `upsert_object_many` options.
func (OperationManyOpts) EncodeMsgpack ¶
func (opts OperationManyOpts) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack provides custom msgpack encoder.
type OperationObjectManyOpts ¶
type OperationObjectManyOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Fields is field names for getting only a subset of fields.
Fields option.Any
// StopOnError is a parameter to stop on a first error and report
// error regarding the failed operation and error about what tuples
// were not performed.
StopOnError option.Bool
// RollbackOnError is a parameter because of what any failed operation
// will lead to rollback on a storage, where the operation is failed.
RollbackOnError option.Bool
// SkipNullabilityCheckOnFlatten is a parameter to allow
// setting null values to non-nullable fields.
SkipNullabilityCheckOnFlatten option.Bool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata option.Bool
// Noreturn suppresses successfully processed data (first return value is `nil`).
// Disabled by default.
Noreturn option.Bool
}
OperationObjectManyOpts describes options for CRUD operations with many objects. It doesn't cover `upsert_object_many` options.
func (OperationObjectManyOpts) EncodeMsgpack ¶
func (opts OperationObjectManyOpts) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack provides custom msgpack encoder.
type Operator ¶
type Operator string
Operator is a type to describe operator of operation.
const ( // Eq - comparison operator for "equal". Eq Operator = "=" // Lt - comparison operator for "less than". Lt Operator = "<" // Le - comparison operator for "less than or equal". Le Operator = "<=" // Gt - comparison operator for "greater than". Gt Operator = ">" // Ge - comparison operator for "greater than or equal". Ge Operator = ">=" )
const ( // Add - operator for addition. Add Operator = "+" // Sub - operator for subtraction. Sub Operator = "-" // And - operator for bitwise AND. And Operator = "&" // Or - operator for bitwise OR. Or Operator = "|" // Xor - operator for bitwise XOR. Xor Operator = "^" // Splice - operator for string splice. Splice Operator = ":" // Insert - operator for insertion of a new field. Insert Operator = "!" // Delete - operator for deletion. Delete Operator = "#" // Assign - operator for assignment. Assign Operator = "=" )
type ReplaceManyOpts ¶
type ReplaceManyOpts = OperationManyOpts
ReplaceManyOpts describes options for `crud.replace_many` method.
type ReplaceManyRequest ¶
type ReplaceManyRequest struct {
// contains filtered or unexported fields
}
ReplaceManyRequest helps you to create request object to call `crud.replace_many` for execution by a Connection.
func NewReplaceManyRequest ¶
func NewReplaceManyRequest(space string) ReplaceManyRequest
NewReplaceManyRequest returns a new empty ReplaceManyRequest.
func (ReplaceManyRequest) Async ¶
func (req ReplaceManyRequest) Async() bool
Async returns is CRUD request expects a response.
func (ReplaceManyRequest) Body ¶
func (req ReplaceManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (ReplaceManyRequest) Context ¶
func (req ReplaceManyRequest) Context(ctx context.Context) ReplaceManyRequest
Context sets a passed context to CRUD request.
func (ReplaceManyRequest) Opts ¶
func (req ReplaceManyRequest) Opts(opts ReplaceManyOpts) ReplaceManyRequest
Opts sets the options for the ReplaceManyRequest request. Note: default value is nil.
func (ReplaceManyRequest) Response ¶
func (req ReplaceManyRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (ReplaceManyRequest) Tuples ¶
func (req ReplaceManyRequest) Tuples(tuples Tuples) ReplaceManyRequest
Tuples sets the tuples for the ReplaceManyRequest request. Note: default value is nil.
type ReplaceObjectManyOpts ¶
type ReplaceObjectManyOpts = OperationObjectManyOpts
ReplaceObjectManyOpts describes options for `crud.replace_object_many` method.
type ReplaceObjectManyRequest ¶
type ReplaceObjectManyRequest struct {
// contains filtered or unexported fields
}
ReplaceObjectManyRequest helps you to create request object to call `crud.replace_object_many` for execution by a Connection.
func NewReplaceObjectManyRequest ¶
func NewReplaceObjectManyRequest(space string) ReplaceObjectManyRequest
NewReplaceObjectManyRequest returns a new empty ReplaceObjectManyRequest.
func (ReplaceObjectManyRequest) Async ¶
func (req ReplaceObjectManyRequest) Async() bool
Async returns is CRUD request expects a response.
func (ReplaceObjectManyRequest) Body ¶
func (req ReplaceObjectManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (ReplaceObjectManyRequest) Context ¶
func (req ReplaceObjectManyRequest) Context(ctx context.Context) ReplaceObjectManyRequest
Context sets a passed context to CRUD request.
func (ReplaceObjectManyRequest) Objects ¶
func (req ReplaceObjectManyRequest) Objects(objects Objects) ReplaceObjectManyRequest
Objects sets the tuple for the ReplaceObjectManyRequest request. Note: default value is nil.
func (ReplaceObjectManyRequest) Opts ¶
func (req ReplaceObjectManyRequest) Opts(opts ReplaceObjectManyOpts) ReplaceObjectManyRequest
Opts sets the options for the ReplaceObjectManyRequest request. Note: default value is nil.
type ReplaceObjectOpts ¶
type ReplaceObjectOpts = SimpleOperationObjectOpts
ReplaceObjectOpts describes options for `crud.replace_object` method.
type ReplaceObjectRequest ¶
type ReplaceObjectRequest struct {
// contains filtered or unexported fields
}
ReplaceObjectRequest helps you to create request object to call `crud.replace_object` for execution by a Connection.
func NewReplaceObjectRequest ¶
func NewReplaceObjectRequest(space string) ReplaceObjectRequest
NewReplaceObjectRequest returns a new empty ReplaceObjectRequest.
func (ReplaceObjectRequest) Async ¶
func (req ReplaceObjectRequest) Async() bool
Async returns is CRUD request expects a response.
func (ReplaceObjectRequest) Body ¶
func (req ReplaceObjectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (ReplaceObjectRequest) Context ¶
func (req ReplaceObjectRequest) Context(ctx context.Context) ReplaceObjectRequest
Context sets a passed context to CRUD request.
func (ReplaceObjectRequest) Object ¶
func (req ReplaceObjectRequest) Object(object Object) ReplaceObjectRequest
Object sets the tuple for the ReplaceObjectRequest request. Note: default value is nil.
func (ReplaceObjectRequest) Opts ¶
func (req ReplaceObjectRequest) Opts(opts ReplaceObjectOpts) ReplaceObjectRequest
Opts sets the options for the ReplaceObjectRequest request. Note: default value is nil.
type ReplaceOpts ¶
type ReplaceOpts = SimpleOperationOpts
ReplaceOpts describes options for `crud.replace` method.
type ReplaceRequest ¶
type ReplaceRequest struct {
// contains filtered or unexported fields
}
ReplaceRequest helps you to create request object to call `crud.replace` for execution by a Connection.
func NewReplaceRequest ¶
func NewReplaceRequest(space string) ReplaceRequest
NewReplaceRequest returns a new empty ReplaceRequest.
func (ReplaceRequest) Async ¶
func (req ReplaceRequest) Async() bool
Async returns is CRUD request expects a response.
func (ReplaceRequest) Body ¶
func (req ReplaceRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (ReplaceRequest) Context ¶
func (req ReplaceRequest) Context(ctx context.Context) ReplaceRequest
Context sets a passed context to CRUD request.
func (ReplaceRequest) Opts ¶
func (req ReplaceRequest) Opts(opts ReplaceOpts) ReplaceRequest
Opts sets the options for the ReplaceRequest request. Note: default value is nil.
func (ReplaceRequest) Response ¶
func (req ReplaceRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (ReplaceRequest) Tuple ¶
func (req ReplaceRequest) Tuple(tuple Tuple) ReplaceRequest
Tuple sets the tuple for the ReplaceRequest request. Note: default value is nil.
type Result ¶
type Result struct {
Metadata []FieldFormat
Rows any
// contains filtered or unexported fields
}
Result describes CRUD result as an object containing metadata and rows.
Example (Error) ¶
ExampleResult_error demonstrates how to use a helper type Result to handle a crud error.
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const exampleServer = "127.0.0.1:3013"
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewReplaceRequest("not_exist").
Tuple([]any{uint(2010), nil, "bla"})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
crudErr := err.(crud.Error)
fmt.Printf("Failed to execute request: %s", crudErr)
} else {
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
}
Output: Failed to execute request: ReplaceError: Space "not_exist" doesn't exist
Example (ErrorMany) ¶
ExampleResult_errorMany demonstrates how to use a helper type Result to handle a crud error for a *ManyRequest.
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
initReq := crud.NewReplaceRequest("not_exist").
Tuple([]any{uint(2010), nil, "bla"})
if _, err := conn.Do(initReq).Get(); err != nil {
fmt.Printf("Failed to initialize the example: %s\n", err)
}
req := crud.NewInsertManyRequest(exampleSpace).
Tuples([]crud.Tuple{
[]any{uint(2010), nil, "bla"},
[]any{uint(2010), nil, "bla"},
})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
crudErr := err.(crud.ErrorMany)
// We need to trim the error message to make the example repeatable.
errmsg := crudErr.Error()[:10]
fmt.Printf("Failed to execute request: %s", errmsg)
} else {
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
}
Output: Failed to execute request: CallError:
Example (Many) ¶
ExampleResult_many demonstrates that there is no difference in a response from *ManyRequest.
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewReplaceManyRequest(exampleSpace).
Tuples([]crud.Tuple{
[]any{uint(2010), nil, "bla"},
[]any{uint(2011), nil, "bla"},
})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
Output: [{id unsigned false} {bucket_id unsigned true} {name string false}] [[2010 45 bla] [2011 4 bla]]
Example (Noreturn) ¶
ExampleResult_noreturn demonstrates noreturn request: a data change request where you don't need to retrieve the result, just want to know whether it was successful or not.
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-option"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewReplaceManyRequest(exampleSpace).
Tuples([]crud.Tuple{
[]any{uint(2010), nil, "bla"},
[]any{uint(2011), nil, "bla"},
}).
Opts(crud.ReplaceManyOpts{
Noreturn: option.SomeBool(true),
})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
Output: [] <nil>
Example (OperationData) ¶
ExampleResult_operationData demonstrates how to obtain information about erroneous objects from crud.Error using `OperationData` field.
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewInsertObjectManyRequest(exampleSpace).Objects([]crud.Object{
crud.MapObject{
"id": 2,
"bucket_id": 3,
"name": "Makar",
},
crud.MapObject{
"id": 2,
"bucket_id": 3,
"name": "Vasya",
},
crud.MapObject{
"id": 3,
"bucket_id": 5,
},
})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
crudErrs := err.(crud.ErrorMany)
fmt.Println("Erroneous data:")
for _, crudErr := range crudErrs.Errors {
fmt.Println(crudErr.OperationData)
}
} else {
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
}
Output: Erroneous data: [2 3 Vasya] map[bucket_id:5 id:3]
Example (OperationDataCustomType) ¶
ExampleResult_operationDataCustomType demonstrates the ability to cast `OperationData` field, extracted from a CRUD error during decoding using crud.Result, to a custom type. The type of `OperationData` is determined as the crud.Result row type.
package main
import (
"context"
"fmt"
"reflect"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewInsertObjectManyRequest(exampleSpace).Objects([]crud.Object{
crud.MapObject{
"id": 1,
"bucket_id": 3,
"name": "Makar",
},
crud.MapObject{
"id": 1,
"bucket_id": 3,
"name": "Vasya",
},
crud.MapObject{
"id": 3,
"bucket_id": 5,
},
})
type Tuple struct {
Id uint64 `msgpack:"id,omitempty"`
BucketId uint64 `msgpack:"bucket_id,omitempty"`
Name string `msgpack:"name,omitempty"`
}
ret := crud.NewResult(reflect.TypeFor[Tuple]())
if err := conn.Do(req).GetTyped(&ret); err != nil {
crudErrs := err.(crud.ErrorMany)
fmt.Println("Erroneous data:")
for _, crudErr := range crudErrs.Errors {
operationData := crudErr.OperationData.(Tuple)
fmt.Println(operationData)
}
} else {
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
}
Output: Erroneous data: {1 3 Vasya} {3 5 }
Example (RowsCustomType) ¶
ExampleResult_rowsCustomType demonstrates how to use a helper type Result to decode a crud response. In this example, rows are decoded as a custom type.
package main
import (
"context"
"fmt"
"reflect"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewReplaceRequest(exampleSpace).
Tuple([]any{uint(2010), nil, "bla"})
type Tuple struct {
_msgpack struct{} `msgpack:",asArray"` //nolint:unused
Id uint64
BucketId uint64
Name string
}
ret := crud.NewResult(reflect.TypeFor[Tuple]())
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
fmt.Println(ret.Metadata)
rows := ret.Rows.([]Tuple)
fmt.Println(rows)
}
Output: [{id unsigned false} {bucket_id unsigned true} {name string false}] [{{} 2010 45 bla}]
Example (RowsInterface) ¶
ExampleResult_rowsInterface demonstrates how to use a helper type Result to decode a crud response. In this example, rows are decoded as an interface{} type.
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewReplaceRequest(exampleSpace).
Tuple([]any{uint(2010), nil, "bla"})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
Output: [{id unsigned false} {bucket_id unsigned true} {name string false}] [[2010 45 bla]]
type Schema ¶
type Schema map[string]SpaceSchema
Schema contains CRUD cluster schema definition.
Example ¶
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const exampleServer = "127.0.0.1:3013"
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
req := crud.NewSchemaRequest()
var result crud.SchemaResult
if err := conn.Do(req).GetTyped(&result); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
// Schema may differ between different Tarantool versions.
// https://github.com/tarantool/tarantool/issues/4091
// https://github.com/tarantool/tarantool/commit/17c9c034933d726925910ce5bf8b20e8e388f6e3
for spaceName, spaceSchema := range result.Value {
fmt.Printf("Space format for '%s' is as follows:\n", spaceName)
for _, field := range spaceSchema.Format {
fmt.Printf(" - field '%s' with type '%s'\n", field.Name, field.Type)
}
}
}
Output: Space format for 'test' is as follows: - field 'id' with type 'unsigned' - field 'bucket_id' with type 'unsigned' - field 'name' with type 'string'
type SchemaOpts ¶
type SchemaOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Cached defines whether router should reload storage schema on call.
Cached option.Bool
}
SchemaOpts describes options for `crud.schema` method.
func (SchemaOpts) EncodeMsgpack ¶
func (opts SchemaOpts) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack provides custom msgpack encoder.
type SchemaRequest ¶
type SchemaRequest struct {
// contains filtered or unexported fields
}
SchemaRequest helps you to create request object to call `crud.schema` for execution by a Connection.
func NewSchemaRequest ¶
func NewSchemaRequest() SchemaRequest
NewSchemaRequest returns a new empty SchemaRequest.
func (SchemaRequest) Async ¶
func (req SchemaRequest) Async() bool
Async returns is CRUD request expects a response.
func (SchemaRequest) Body ¶
func (req SchemaRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (SchemaRequest) Context ¶
func (req SchemaRequest) Context(ctx context.Context) SchemaRequest
Context sets a passed context to CRUD request.
func (SchemaRequest) Opts ¶
func (req SchemaRequest) Opts(opts SchemaOpts) SchemaRequest
Opts sets the options for the SchemaRequest request. Note: default value is nil.
func (SchemaRequest) Response ¶
func (req SchemaRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (SchemaRequest) Space ¶
func (req SchemaRequest) Space(space string) SchemaRequest
Space sets the space name for the SchemaRequest request. Note: default value is nil.
type SchemaResult ¶
type SchemaResult struct {
Value Schema
}
SchemaResult contains a schema request result for all spaces.
func (*SchemaResult) DecodeMsgpack ¶
func (result *SchemaResult) DecodeMsgpack(d *msgpack.Decoder) error
DecodeMsgpack provides custom msgpack decoder.
type SelectOpts ¶
type SelectOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Fields is field names for getting only a subset of fields.
Fields option.Any
// BucketId is a bucket ID.
BucketId option.Uint
// Mode is a parameter with `write`/`read` possible values,
// if `write` is specified then operation is performed on master.
Mode option.String
// PreferReplica is a parameter to specify preferred target
// as one of the replicas.
PreferReplica option.Bool
// Balance is a parameter to use replica according to vshard
// load balancing policy.
Balance option.Bool
// First describes the maximum count of the objects to return.
First option.Int64
// After is a tuple after which objects should be selected.
After option.Any
// BatchSize is a number of tuples to process per one request to storage.
BatchSize option.Uint
// ForceMapCall describes the map call is performed without any
// optimizations even if full primary key equal condition is specified.
ForceMapCall option.Bool
// Fullscan describes if a critical log entry will be skipped on
// potentially long select.
Fullscan option.Bool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata option.Bool
// YieldEvery describes number of tuples processed to yield after.
// Should be positive.
YieldEvery option.Uint
}
SelectOpts describes options for `crud.select` method.
func (SelectOpts) EncodeMsgpack ¶
func (opts SelectOpts) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack provides custom msgpack encoder.
type SelectRequest ¶
type SelectRequest struct {
// contains filtered or unexported fields
}
SelectRequest helps you to create request object to call `crud.select` for execution by a Connection.
Example (Pagination) ¶
package main
import (
"context"
"fmt"
"time"
"github.com/tarantool/go-option"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
const (
fromTuple = 5
allTuples = 10
)
var tuple any
for i := range allTuples {
req := crud.NewReplaceRequest(exampleSpace).
Tuple([]any{uint(3000 + i), nil, "bla"})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to initialize the example: %s\n", err)
return
}
if i == fromTuple {
tuple = ret.Rows.([]any)[0]
}
}
req := crud.NewSelectRequest(exampleSpace).
Opts(crud.SelectOpts{
First: option.SomeInt64(2),
After: option.SomeAny(tuple),
})
ret := crud.Result{}
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
fmt.Println(ret.Metadata)
fmt.Println(ret.Rows)
}
Output: [{id unsigned false} {bucket_id unsigned true} {name string false}] [[3006 32 bla] [3007 33 bla]]
func NewSelectRequest ¶
func NewSelectRequest(space string) SelectRequest
NewSelectRequest returns a new empty SelectRequest.
func (SelectRequest) Async ¶
func (req SelectRequest) Async() bool
Async returns is CRUD request expects a response.
func (SelectRequest) Body ¶
func (req SelectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (SelectRequest) Conditions ¶
func (req SelectRequest) Conditions(conditions []Condition) SelectRequest
Conditions sets the conditions for the SelectRequest request. Note: default value is nil.
func (SelectRequest) Context ¶
func (req SelectRequest) Context(ctx context.Context) SelectRequest
Context sets a passed context to CRUD request.
func (SelectRequest) Opts ¶
func (req SelectRequest) Opts(opts SelectOpts) SelectRequest
Opts sets the options for the SelectRequest request. Note: default value is nil.
type SimpleOperationObjectOpts ¶
type SimpleOperationObjectOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Fields is field names for getting only a subset of fields.
Fields option.Any
// BucketId is a bucket ID.
BucketId option.Uint
// SkipNullabilityCheckOnFlatten is a parameter to allow
// setting null values to non-nullable fields.
SkipNullabilityCheckOnFlatten option.Bool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata option.Bool
// Noreturn suppresses successfully processed data (first return value is `nil`).
// Disabled by default.
Noreturn option.Bool
}
SimpleOperationObjectOpts describes options for simple CRUD operations with objects. It doesn't cover `upsert_object` options.
func (SimpleOperationObjectOpts) EncodeMsgpack ¶
func (opts SimpleOperationObjectOpts) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack provides custom msgpack encoder.
type SimpleOperationOpts ¶
type SimpleOperationOpts struct {
// Timeout is a `vshard.call` timeout and vshard
// master discovery timeout (in seconds).
Timeout option.Float64
// VshardRouter is cartridge vshard group name or
// vshard router instance.
VshardRouter option.String
// Fields is field names for getting only a subset of fields.
Fields option.Any
// BucketId is a bucket ID.
BucketId option.Uint
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata option.Bool
// Noreturn suppresses successfully processed data (first return value is `nil`).
// Disabled by default.
Noreturn option.Bool
}
SimpleOperationOpts describes options for simple CRUD operations. It also covers `upsert_object` options.
func (SimpleOperationOpts) EncodeMsgpack ¶
func (opts SimpleOperationOpts) EncodeMsgpack(enc *msgpack.Encoder) error
EncodeMsgpack provides custom msgpack encoder.
type SpaceSchema ¶
type SpaceSchema struct {
Format []FieldFormat `msgpack:"format"`
Indexes map[uint32]Index `msgpack:"indexes"`
}
SpaceSchema contains a single CRUD space schema definition.
type SpaceSchemaResult ¶
type SpaceSchemaResult struct {
Value SpaceSchema
}
SpaceSchemaResult contains a schema request result for a single space.
func (*SpaceSchemaResult) DecodeMsgpack ¶
func (result *SpaceSchemaResult) DecodeMsgpack(d *msgpack.Decoder) error
DecodeMsgpack provides custom msgpack decoder.
type StatsRequest ¶
type StatsRequest struct {
// contains filtered or unexported fields
}
StatsRequest helps you to create request object to call `crud.stats` for execution by a Connection.
func NewStatsRequest ¶
func NewStatsRequest() StatsRequest
NewStatsRequest returns a new empty StatsRequest.
func (StatsRequest) Async ¶
func (req StatsRequest) Async() bool
Async returns is CRUD request expects a response.
func (StatsRequest) Body ¶
func (req StatsRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (StatsRequest) Context ¶
func (req StatsRequest) Context(ctx context.Context) StatsRequest
Context sets a passed context to CRUD request.
func (StatsRequest) Response ¶
func (req StatsRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (StatsRequest) Space ¶
func (req StatsRequest) Space(space string) StatsRequest
Space sets the space name for the StatsRequest request. Note: default value is nil.
type StatusTable ¶
StatusTable describes information for instance.
func (*StatusTable) DecodeMsgpack ¶
func (statusTable *StatusTable) DecodeMsgpack(d *msgpack.Decoder) error
DecodeMsgpack provides custom msgpack decoder.
type StorageInfoOpts ¶
type StorageInfoOpts = BaseOpts
StorageInfoOpts describes options for `crud.storage_info` method.
type StorageInfoRequest ¶
type StorageInfoRequest struct {
// contains filtered or unexported fields
}
StorageInfoRequest helps you to create request object to call `crud.storage_info` for execution by a Connection.
func NewStorageInfoRequest ¶
func NewStorageInfoRequest() StorageInfoRequest
NewStorageInfoRequest returns a new empty StorageInfoRequest.
func (StorageInfoRequest) Async ¶
func (req StorageInfoRequest) Async() bool
Async returns is CRUD request expects a response.
func (StorageInfoRequest) Body ¶
func (req StorageInfoRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (StorageInfoRequest) Context ¶
func (req StorageInfoRequest) Context(ctx context.Context) StorageInfoRequest
Context sets a passed context to CRUD request.
func (StorageInfoRequest) Opts ¶
func (req StorageInfoRequest) Opts(opts StorageInfoOpts) StorageInfoRequest
Opts sets the options for the torageInfoRequest request. Note: default value is nil.
type StorageInfoResult ¶
type StorageInfoResult struct {
Info map[string]StatusTable
}
StorageInfoResult describes result for `crud.storage_info` method.
func (*StorageInfoResult) DecodeMsgpack ¶
func (r *StorageInfoResult) DecodeMsgpack(d *msgpack.Decoder) error
DecodeMsgpack provides custom msgpack decoder.
type TruncateOpts ¶
type TruncateOpts = BaseOpts
TruncateOpts describes options for `crud.truncate` method.
type TruncateRequest ¶
type TruncateRequest struct {
// contains filtered or unexported fields
}
TruncateRequest helps you to create request object to call `crud.truncate` for execution by a Connection.
func NewTruncateRequest ¶
func NewTruncateRequest(space string) TruncateRequest
NewTruncateRequest returns a new empty TruncateRequest.
func (TruncateRequest) Async ¶
func (req TruncateRequest) Async() bool
Async returns is CRUD request expects a response.
func (TruncateRequest) Body ¶
func (req TruncateRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (TruncateRequest) Context ¶
func (req TruncateRequest) Context(ctx context.Context) TruncateRequest
Context sets a passed context to CRUD request.
func (TruncateRequest) Opts ¶
func (req TruncateRequest) Opts(opts TruncateOpts) TruncateRequest
Opts sets the options for the TruncateRequest request. Note: default value is nil.
type TruncateResult ¶
type TruncateResult = BoolResult
TruncateResult describes result for `crud.truncate` method.
type Tuple ¶
type Tuple = any
Tuple is a type to describe tuple for CRUD methods. It can be any type that msgpask can encode as an array.
type TupleOperationsData ¶
type TupleOperationsData struct {
Tuple Tuple
Operations []Operation
// contains filtered or unexported fields
}
TupleOperationsData contains tuple with operations to be applied to tuple.
type Tuples ¶
type Tuples = any
Tuples is a type to describe an array of tuples for CRUD methods. It can be any type that msgpack can encode, but encoded data must be an array of tuples.
See the reason why not just []Tuple: https://github.com/tarantool/go-tarantool/issues/365
Example (CustomType) ¶
ExampleTuples_customType demonstrates how to use a slice of objects of a custom type as Tuples to make a ReplaceManyRequest.
package main
import (
"context"
"fmt"
"reflect"
"time"
"github.com/tarantool/go-tarantool/v3"
"github.com/tarantool/go-tarantool/v3/crud"
)
const (
exampleServer = "127.0.0.1:3013"
exampleSpace = "test"
)
var exampleOpts = tarantool.Opts{
Timeout: 5 * time.Second,
}
var exampleDialer = tarantool.NetDialer{
Address: exampleServer,
User: "test",
Password: "test",
}
func exampleConnect() *tarantool.Connection {
ctx, cancel := context.WithTimeout(context.Background(), 500*time.Millisecond)
defer cancel()
conn, err := tarantool.Connect(ctx, exampleDialer, exampleOpts)
if err != nil {
panic("Connection is not established: " + err.Error())
}
return conn
}
func main() {
conn := exampleConnect()
// The type will be encoded/decoded as an array.
type Tuple struct {
_msgpack struct{} `msgpack:",asArray"` //nolint:unused
Id uint64
BucketId *uint64
Name string
}
req := crud.NewReplaceManyRequest(exampleSpace).Tuples([]Tuple{
Tuple{
Id: 2010,
BucketId: nil,
Name: "bla",
},
})
ret := crud.NewResult(reflect.TypeFor[Tuple]())
if err := conn.Do(req).GetTyped(&ret); err != nil {
fmt.Printf("Failed to execute request: %s", err)
return
}
fmt.Println(ret.Metadata)
rows := ret.Rows.([]Tuple)
if len(rows) == 1 {
fmt.Println(rows[0].Id)
fmt.Println(*rows[0].BucketId)
fmt.Println(rows[0].Name)
} else {
fmt.Printf("Unexpected result tuples count: %d", len(rows))
}
}
Output: [{id unsigned false} {bucket_id unsigned true} {name string false}] 2010 45 bla
type UpdateOpts ¶
type UpdateOpts = SimpleOperationOpts
UpdateOpts describes options for `crud.update` method.
type UpdateRequest ¶
type UpdateRequest struct {
// contains filtered or unexported fields
}
UpdateRequest helps you to create request object to call `crud.update` for execution by a Connection.
func NewUpdateRequest ¶
func NewUpdateRequest(space string) UpdateRequest
NewUpdateRequest returns a new empty UpdateRequest.
func (UpdateRequest) Async ¶
func (req UpdateRequest) Async() bool
Async returns is CRUD request expects a response.
func (UpdateRequest) Body ¶
func (req UpdateRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (UpdateRequest) Context ¶
func (req UpdateRequest) Context(ctx context.Context) UpdateRequest
Context sets a passed context to CRUD request.
func (UpdateRequest) Key ¶
func (req UpdateRequest) Key(key Tuple) UpdateRequest
Key sets the key for the UpdateRequest request. Note: default value is nil.
func (UpdateRequest) Operations ¶
func (req UpdateRequest) Operations(operations []Operation) UpdateRequest
Operations sets the operations for UpdateRequest request. Note: default value is nil.
func (UpdateRequest) Opts ¶
func (req UpdateRequest) Opts(opts UpdateOpts) UpdateRequest
Opts sets the options for the UpdateRequest request. Note: default value is nil.
type UpsertManyOpts ¶
type UpsertManyOpts = OperationManyOpts
UpsertManyOpts describes options for `crud.upsert_many` method.
type UpsertManyRequest ¶
type UpsertManyRequest struct {
// contains filtered or unexported fields
}
UpsertManyRequest helps you to create request object to call `crud.upsert_many` for execution by a Connection.
func NewUpsertManyRequest ¶
func NewUpsertManyRequest(space string) UpsertManyRequest
NewUpsertManyRequest returns a new empty UpsertManyRequest.
func (UpsertManyRequest) Async ¶
func (req UpsertManyRequest) Async() bool
Async returns is CRUD request expects a response.
func (UpsertManyRequest) Body ¶
func (req UpsertManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (UpsertManyRequest) Context ¶
func (req UpsertManyRequest) Context(ctx context.Context) UpsertManyRequest
Context sets a passed context to CRUD request.
func (UpsertManyRequest) Opts ¶
func (req UpsertManyRequest) Opts(opts UpsertManyOpts) UpsertManyRequest
Opts sets the options for the UpsertManyRequest request. Note: default value is nil.
func (UpsertManyRequest) Response ¶
func (req UpsertManyRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (UpsertManyRequest) TuplesOperationsData ¶
func (req UpsertManyRequest) TuplesOperationsData( tuplesOperationData []TupleOperationsData) UpsertManyRequest
TuplesOperationsData sets tuples and operations for the UpsertManyRequest request. Note: default value is nil.
type UpsertObjectManyOpts ¶
type UpsertObjectManyOpts = OperationManyOpts
UpsertObjectManyOpts describes options for `crud.upsert_object_many` method.
type UpsertObjectManyRequest ¶
type UpsertObjectManyRequest struct {
// contains filtered or unexported fields
}
UpsertObjectManyRequest helps you to create request object to call `crud.upsert_object_many` for execution by a Connection.
func NewUpsertObjectManyRequest ¶
func NewUpsertObjectManyRequest(space string) UpsertObjectManyRequest
NewUpsertObjectManyRequest returns a new empty UpsertObjectManyRequest.
func (UpsertObjectManyRequest) Async ¶
func (req UpsertObjectManyRequest) Async() bool
Async returns is CRUD request expects a response.
func (UpsertObjectManyRequest) Body ¶
func (req UpsertObjectManyRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (UpsertObjectManyRequest) Context ¶
func (req UpsertObjectManyRequest) Context(ctx context.Context) UpsertObjectManyRequest
Context sets a passed context to CRUD request.
func (UpsertObjectManyRequest) ObjectsOperationsData ¶
func (req UpsertObjectManyRequest) ObjectsOperationsData( objectsOperationData []ObjectOperationsData) UpsertObjectManyRequest
ObjectsOperationsData sets objects and operations for the UpsertObjectManyRequest request. Note: default value is nil.
func (UpsertObjectManyRequest) Opts ¶
func (req UpsertObjectManyRequest) Opts(opts UpsertObjectManyOpts) UpsertObjectManyRequest
Opts sets the options for the UpsertObjectManyRequest request. Note: default value is nil.
type UpsertObjectOpts ¶
type UpsertObjectOpts = SimpleOperationOpts
UpsertObjectOpts describes options for `crud.upsert_object` method.
type UpsertObjectRequest ¶
type UpsertObjectRequest struct {
// contains filtered or unexported fields
}
UpsertObjectRequest helps you to create request object to call `crud.upsert_object` for execution by a Connection.
func NewUpsertObjectRequest ¶
func NewUpsertObjectRequest(space string) UpsertObjectRequest
NewUpsertObjectRequest returns a new empty UpsertObjectRequest.
func (UpsertObjectRequest) Async ¶
func (req UpsertObjectRequest) Async() bool
Async returns is CRUD request expects a response.
func (UpsertObjectRequest) Body ¶
func (req UpsertObjectRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (UpsertObjectRequest) Context ¶
func (req UpsertObjectRequest) Context(ctx context.Context) UpsertObjectRequest
Context sets a passed context to CRUD request.
func (UpsertObjectRequest) Object ¶
func (req UpsertObjectRequest) Object(object Object) UpsertObjectRequest
Object sets the tuple for the UpsertObjectRequest request. Note: default value is nil.
func (UpsertObjectRequest) Operations ¶
func (req UpsertObjectRequest) Operations(operations []Operation) UpsertObjectRequest
Operations sets the operations for the UpsertObjectRequest request. Note: default value is nil.
func (UpsertObjectRequest) Opts ¶
func (req UpsertObjectRequest) Opts(opts UpsertObjectOpts) UpsertObjectRequest
Opts sets the options for the UpsertObjectRequest request. Note: default value is nil.
type UpsertOpts ¶
type UpsertOpts = SimpleOperationOpts
UpsertOpts describes options for `crud.upsert` method.
type UpsertRequest ¶
type UpsertRequest struct {
// contains filtered or unexported fields
}
UpsertRequest helps you to create request object to call `crud.upsert` for execution by a Connection.
func NewUpsertRequest ¶
func NewUpsertRequest(space string) UpsertRequest
NewUpsertRequest returns a new empty UpsertRequest.
func (UpsertRequest) Async ¶
func (req UpsertRequest) Async() bool
Async returns is CRUD request expects a response.
func (UpsertRequest) Body ¶
func (req UpsertRequest) Body(res tarantool.SchemaResolver, enc *msgpack.Encoder) error
Body fills an encoder with the call request body.
func (UpsertRequest) Context ¶
func (req UpsertRequest) Context(ctx context.Context) UpsertRequest
Context sets a passed context to CRUD request.
func (UpsertRequest) Operations ¶
func (req UpsertRequest) Operations(operations []Operation) UpsertRequest
Operations sets the operations for the UpsertRequest request. Note: default value is nil.
func (UpsertRequest) Opts ¶
func (req UpsertRequest) Opts(opts UpsertOpts) UpsertRequest
Opts sets the options for the UpsertRequest request. Note: default value is nil.
func (UpsertRequest) Response ¶
func (req UpsertRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the baseRequest.
func (UpsertRequest) Tuple ¶
func (req UpsertRequest) Tuple(tuple Tuple) UpsertRequest
Tuple sets the tuple for the UpsertRequest request. Note: default value is nil.