module tarantool.request

Request types definitions. For internal use only, there is no API to send pre-build request objects.

class tarantool.request.Request(conn)

Represents a single request to the server in compliance with the Tarantool protocol. Responsible for data encapsulation and building the binary packet to be sent to the server.

This is the abstract base class. Specific request types are implemented in the inherited classes.

Parameters:

conn (Connection) – Request sender.

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestAuthenticate(conn, salt, user, password, auth_type='chap-sha1')

Represents AUTHENTICATE request.

Parameters:
  • conn (Connection) – Request sender.

  • salt (str) – base64-encoded session salt.

  • user (str) – User name for authentication on the Tarantool server.

  • password (str) – User password for authentication on the Tarantool server.

  • auth_type (str, optional) – Refer to auth_type.

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestCall(conn, name, args, call_16)

Represents CALL request.

Parameters:
  • conn (Connection) – Request sender.

  • name – Stored Lua function name.

  • args (tuple) – Stored Lua function arguments.

  • call_16 (bool) – If True, use compatibility mode with Tarantool 1.6 or older.

Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestDelete(conn, space_no, index_no, key)

Represents DELETE request.

Parameters:
  • conn (Connection) – Request sender.

  • space_no (int) – Space id.

  • index_no (int) – Index id.

  • key (list) – Key of a tuple to be deleted.

Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestEval(conn, name, args)

Represents EVAL request.

Parameters:
  • conn (Connection) – Request sender.

  • name – Lua expression.

  • args (tuple) – Lua expression arguments.

Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestExecute(conn, sql, args)

Represents EXECUTE SQL request.

Parameters:
Raise:

TypeError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestInsert(conn, space_no, values)

Represents INSERT request.

Parameters:
Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestOK(conn, sync)

Represents OK acknowledgement.

Parameters:
header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestPing(conn)

Represents a ping request with the empty body.

Parameters:

conn (Connection) – Request sender.

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestProtocolVersion(conn, protocol_version, features)

Represents ID request: inform the server about the protocol version and features connector support.

Parameters:
  • conn (Connection) – Request sender.

  • protocol_version (int) – Connector protocol version.

  • features (list) – List of supported features.

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestReplace(conn, space_no, values)

Represents REPLACE request.

Parameters:
Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestSelect(conn, space_no, index_no, key, offset, limit, iterator)

Represents SELECT request.

Parameters:
  • conn (Connection) – Request sender.

  • space_no (int) – Space id.

  • index_no (int) – Index id.

  • key (list) – Key of a tuple to be selected.

  • offset (int) – Number of tuples to skip.

  • limit (int) – Maximum number of tuples to select.

  • iterator (str) – Index iterator type, see iterator.

Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestUpdate(conn, space_no, index_no, key, op_list)

Represents UPDATE request.

Parameters:
  • conn (Connection) – Request sender.

  • space_no (int) – Space id.

  • index_no (int) – Index id.

  • key (list) – Key of a tuple to be updated.

  • op_list (tuple or list) – The list of operations to update individual fields, refer to op_list.

Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

class tarantool.request.RequestUpsert(conn, space_no, index_no, tuple_value, op_list)

Represents UPSERT request.

Parameters:
  • conn (Connection) – Request sender.

  • space_no (int) – Space id.

  • index_no (int) – Index id.

  • tuple_value (tuple or list) – Tuple to be upserted.

  • op_list (tuple or list) – The list of operations to update individual fields, refer to op_list.

Raise:

AssertionError

header(length)

Pack total (header + payload) length info together with header itself.

Parameters:

length – Payload length.

Type:

int

Returns:

MsgPack data with encoded total (header + payload) length info and header.

Return type:

bytes

property sync
Type:

int

Contains request header IPROTO_SYNC.

tarantool.request.packer_factory(conn)

Build packer to pack request.

Parameters:

conn (Connection) – Request sender.

Return type:

msgpack.Packer