crud

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: BSD-2-Clause Imports: 10 Imported by: 0

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

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.

func (BaseOpts) EncodeMsgpack

func (opts BaseOpts) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack provides custom msgpack encoder.

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.

func (CountOpts) EncodeMsgpack

func (opts CountOpts) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack provides custom msgpack encoder.

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

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) Ctx

func (req CountRequest) Ctx() context.Context

Ctx returns a context of 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.

func (CountRequest) Response

func (req CountRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (CountRequest) Type

func (req CountRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

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) Ctx

func (req DeleteRequest) Ctx() context.Context

Ctx returns a context of 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.

func (DeleteRequest) Response

func (req DeleteRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (DeleteRequest) Type

func (req DeleteRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

func (e *Error) DecodeMsgpack(d *msgpack.Decoder) error

DecodeMsgpack provides custom msgpack decoder.

func (Error) Error

func (e Error) Error() string

Error converts an Error to a string.

type ErrorMany

type ErrorMany struct {
	Errors []Error
	// contains filtered or unexported fields
}

ErrorMany describes CRUD error object for `_many` methods.

func (*ErrorMany) DecodeMsgpack

func (e *ErrorMany) DecodeMsgpack(d *msgpack.Decoder) error

DecodeMsgpack provides custom msgpack decoder.

func (ErrorMany) Error

func (e ErrorMany) Error() string

Error converts an Error to a string.

type FieldFormat

type FieldFormat struct {
	Name       string
	Type       string
	IsNullable bool
}

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.

func (GetOpts) EncodeMsgpack

func (opts GetOpts) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack provides custom msgpack encoder.

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

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) Ctx

func (req GetRequest) Ctx() context.Context

Ctx returns a context of 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.

func (GetRequest) Response

func (req GetRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (GetRequest) Type

func (req GetRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (InsertManyRequest) Context

Context sets a passed context to CRUD request.

func (InsertManyRequest) Ctx

func (req InsertManyRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (InsertManyRequest) Opts

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.

func (InsertManyRequest) Type

func (req InsertManyRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (InsertObjectManyRequest) Context

Context sets a passed context to CRUD request.

func (InsertObjectManyRequest) Ctx

func (req InsertObjectManyRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (InsertObjectManyRequest) Objects

Objects sets the objects for the InsertObjectManyRequest request. Note: default value is nil.

func (InsertObjectManyRequest) Opts

Opts sets the options for the InsertObjectManyRequest request. Note: default value is nil.

func (InsertObjectManyRequest) Response

func (req InsertObjectManyRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (InsertObjectManyRequest) Type

func (req InsertObjectManyRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (InsertObjectRequest) Context

Context sets a passed context to CRUD request.

func (InsertObjectRequest) Ctx

func (req InsertObjectRequest) Ctx() context.Context

Ctx returns a context of 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

Opts sets the options for the InsertObjectRequest request. Note: default value is nil.

func (InsertObjectRequest) Response

func (req InsertObjectRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (InsertObjectRequest) Type

func (req InsertObjectRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

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) Ctx

func (req InsertRequest) Ctx() context.Context

Ctx returns a context of 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.

func (InsertRequest) Type

func (req InsertRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

type LenOpts

type LenOpts = BaseOpts

LenOpts describes options for `crud.len` method.

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

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) Ctx

func (req LenRequest) Ctx() context.Context

Ctx returns a context of 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.

func (LenRequest) Response

func (req LenRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (LenRequest) Type

func (req LenRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

type LenResult

type LenResult = NumberResult

LenResult describes result for `crud.len` method.

type MapObject

type MapObject map[string]any

MapObject is a type to describe object as a map.

func UnflattenRows

func UnflattenRows(tuples []any, format []any) ([]MapObject, error)

UnflattenRows can be used to convert received tuples to objects.

func (MapObject) EncodeMsgpack

func (o MapObject) EncodeMsgpack(enc *msgpack.Encoder)

type MaxOpts

type MaxOpts = BorderOpts

MaxOpts describes options for `crud.max` method.

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

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) Ctx

func (req MaxRequest) Ctx() context.Context

Ctx returns a context of 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.

func (MaxRequest) Response

func (req MaxRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (MaxRequest) Type

func (req MaxRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

type MinOpts

type MinOpts = BorderOpts

MinOpts describes options for `crud.min` method.

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

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) Ctx

func (req MinRequest) Ctx() context.Context

Ctx returns a context of 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.

func (MinRequest) Response

func (req MinRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (MinRequest) Type

func (req MinRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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}.

func (Operation) EncodeMsgpack

func (o Operation) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack encodes Operation.

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

Body fills an encoder with the call request body.

func (ReplaceManyRequest) Context

Context sets a passed context to CRUD request.

func (ReplaceManyRequest) Ctx

func (req ReplaceManyRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (ReplaceManyRequest) Opts

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.

func (ReplaceManyRequest) Type

func (req ReplaceManyRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (ReplaceObjectManyRequest) Context

Context sets a passed context to CRUD request.

func (ReplaceObjectManyRequest) Ctx

func (req ReplaceObjectManyRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (ReplaceObjectManyRequest) Objects

Objects sets the tuple for the ReplaceObjectManyRequest request. Note: default value is nil.

func (ReplaceObjectManyRequest) Opts

Opts sets the options for the ReplaceObjectManyRequest request. Note: default value is nil.

func (ReplaceObjectManyRequest) Response

func (req ReplaceObjectManyRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (ReplaceObjectManyRequest) Type

func (req ReplaceObjectManyRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (ReplaceObjectRequest) Context

Context sets a passed context to CRUD request.

func (ReplaceObjectRequest) Ctx

func (req ReplaceObjectRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (ReplaceObjectRequest) Object

Object sets the tuple for the ReplaceObjectRequest request. Note: default value is nil.

func (ReplaceObjectRequest) Opts

Opts sets the options for the ReplaceObjectRequest request. Note: default value is nil.

func (ReplaceObjectRequest) Response

func (req ReplaceObjectRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (ReplaceObjectRequest) Type

func (req ReplaceObjectRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

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) Ctx

func (req ReplaceRequest) Ctx() context.Context

Ctx returns a context of 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.

func (ReplaceRequest) Type

func (req ReplaceRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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]]

func NewResult

func NewResult(rowType reflect.Type) Result

NewResult create a Result object with a custom row type for decoding.

func (*Result) DecodeMsgpack

func (r *Result) DecodeMsgpack(d *msgpack.Decoder) error

DecodeMsgpack provides custom msgpack decoder.

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'

func (*Schema) DecodeMsgpack

func (schema *Schema) DecodeMsgpack(d *msgpack.Decoder) error

DecodeMsgpack provides custom msgpack decoder.

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

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) Ctx

func (req SchemaRequest) Ctx() context.Context

Ctx returns a context of 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.

func (SchemaRequest) Type

func (req SchemaRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

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) Ctx

func (req SelectRequest) Ctx() context.Context

Ctx returns a context of 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.

func (SelectRequest) Response

func (req SelectRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (SelectRequest) Type

func (req SelectRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

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) Ctx

func (req StatsRequest) Ctx() context.Context

Ctx returns a context of 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.

func (StatsRequest) Type

func (req StatsRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

type StatusTable

type StatusTable struct {
	Status   string
	IsMaster bool
	Message  string
}

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

Body fills an encoder with the call request body.

func (StorageInfoRequest) Context

Context sets a passed context to CRUD request.

func (StorageInfoRequest) Ctx

func (req StorageInfoRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (StorageInfoRequest) Opts

Opts sets the options for the torageInfoRequest request. Note: default value is nil.

func (StorageInfoRequest) Response

func (req StorageInfoRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (StorageInfoRequest) Type

func (req StorageInfoRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (TruncateRequest) Context

Context sets a passed context to CRUD request.

func (TruncateRequest) Ctx

func (req TruncateRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (TruncateRequest) Opts

Opts sets the options for the TruncateRequest request. Note: default value is nil.

func (TruncateRequest) Response

func (req TruncateRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (TruncateRequest) Type

func (req TruncateRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

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) Ctx

func (req UpdateRequest) Ctx() context.Context

Ctx returns a context of 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.

func (UpdateRequest) Response

func (req UpdateRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (UpdateRequest) Type

func (req UpdateRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (UpsertManyRequest) Context

Context sets a passed context to CRUD request.

func (UpsertManyRequest) Ctx

func (req UpsertManyRequest) Ctx() context.Context

Ctx returns a context of CRUD request.

func (UpsertManyRequest) Opts

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.

func (UpsertManyRequest) Type

func (req UpsertManyRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (UpsertObjectManyRequest) Context

Context sets a passed context to CRUD request.

func (UpsertObjectManyRequest) Ctx

func (req UpsertObjectManyRequest) Ctx() context.Context

Ctx returns a context of 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

Opts sets the options for the UpsertObjectManyRequest request. Note: default value is nil.

func (UpsertObjectManyRequest) Response

func (req UpsertObjectManyRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (UpsertObjectManyRequest) Type

func (req UpsertObjectManyRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

Body fills an encoder with the call request body.

func (UpsertObjectRequest) Context

Context sets a passed context to CRUD request.

func (UpsertObjectRequest) Ctx

func (req UpsertObjectRequest) Ctx() context.Context

Ctx returns a context of 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

Opts sets the options for the UpsertObjectRequest request. Note: default value is nil.

func (UpsertObjectRequest) Response

func (req UpsertObjectRequest) Response(
	header tarantool.Header,
	body io.Reader,
) (tarantool.Response, error)

Response creates a response for the baseRequest.

func (UpsertObjectRequest) Type

func (req UpsertObjectRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

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

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) Ctx

func (req UpsertRequest) Ctx() context.Context

Ctx returns a context of 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.

func (UpsertRequest) Type

func (req UpsertRequest) Type() iproto.Type

Type returns IPROTO type for CRUD request.

Jump to

Keyboard shortcuts

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