pyignite.aio_client module

class pyignite.aio_client.AioClient(compact_footer: Optional[bool] = None, partition_aware: bool = True, event_listeners: Optional[Sequence] = None, **kwargs)

Bases: pyignite.client.BaseClient

Asynchronous Client implementation.

__init__(compact_footer: Optional[bool] = None, partition_aware: bool = True, event_listeners: Optional[Sequence] = None, **kwargs)

Initialize client.

For the use of the SSL-related parameters see https://docs.python.org/3/library/ssl.html#ssl-certificates.

Parameters
  • compact_footer – (optional) use compact (True, recommended) or full (False) schema approach when serializing Complex objects. Default is to use the same approach the server is using (None). Apache Ignite binary protocol documentation on this topic: https://ignite.apache.org/docs/latest/binary-client-protocol/data-format#schema

  • partition_aware – (optional) try to calculate the exact data placement from the key before to issue the key operation to the server node, True by default,

  • event_listeners – (optional) event listeners,

  • handshake_timeout – (optional) sets timeout (in seconds) for performing handshake (connection) with node. Default is 10.0 seconds,

  • use_ssl – (optional) set to True if Ignite server uses SSL on its binary connector. Defaults to use SSL when username and password has been supplied, not to use SSL otherwise,

  • ssl_version – (optional) SSL version constant from standard ssl module. Defaults to TLS v1.2,

  • ssl_ciphers – (optional) ciphers to use. If not provided, ssl default ciphers are used,

  • ssl_cert_reqs

    (optional) determines how the remote side certificate is treated:

    • ssl.CERT_NONE − remote certificate is ignored (default),

    • ssl.CERT_OPTIONAL − remote certificate will be validated, if provided,

    • ssl.CERT_REQUIRED − valid remote certificate is required,

  • ssl_keyfile – (optional) a path to SSL key file to identify local (client) party,

  • ssl_keyfile_password – (optional) password for SSL key file, can be provided when key file is encrypted to prevent OpenSSL password prompt,

  • ssl_certfile – (optional) a path to ssl certificate file to identify local (client) party,

  • ssl_ca_certfile – (optional) a path to a trusted certificate or a certificate chain. Required to check the validity of the remote (server-side) certificate,

  • username – (optional) user name to authenticate to Ignite cluster,

  • password – (optional) password to authenticate to Ignite cluster.

async close()
connect(*args)

Connect to Ignite cluster node(s).

Parameters

args – (optional) host(s) and port(s) to connect to.

async create_cache(settings: Union[str, dict]) pyignite.aio_cache.AioCache

Creates Ignite cache by name. Raises CacheError if such a cache is already exists.

Parameters

settings – cache name or dict of cache properties’ codes and values. All cache properties are documented here: Cache Properties. See also the cache creation example,

Returns

Cache object.

async get_best_node(cache: Union[int, str, BaseCache], key: Any = None, key_hint: IgniteDataType = None) AioConnection

Returns the node from the list of the nodes, opened by client, that most probably contains the needed key-value pair. See IEP-23.

This method is not a part of the public API. Unless you wish to extend the pyignite capabilities (with additional testing, logging, examining connections, et c.) you probably should not use it.

Parameters
  • cache – Ignite cache, cache name or cache id,

  • key – (optional) pythonic key,

  • key_hint – (optional) Ignite data type, for which the given key should be converted,

Returns

Ignite connection object.

async get_binary_type(binary_type: Union[str, int]) dict

Gets the binary type information from the Ignite server. This is quite a low-level implementation of Ignite thin client protocol’s OP_GET_BINARY_TYPE operation. You would probably want to use query_binary_type() instead.

Parameters

binary_type – binary type name or ID,

Returns

binary type description − a dict with the following fields:

  • type_exists: True if the type is registered, False otherwise. In the latter case all the following fields are omitted,

  • type_id: Complex object type ID,

  • type_name: Complex object type name,

  • affinity_key_field: string value or None,

  • is_enum: False in case of Complex object registration,

  • schemas: a list, containing the Complex object schemas in format: OrderedDict[field name: field type hint]. A schema can be empty.

async get_cache(settings: Union[str, dict]) pyignite.aio_cache.AioCache

Creates Cache object with a given cache name without checking it up on server. If such a cache does not exist, some kind of exception (most probably CacheError) may be raised later.

Parameters

settings – cache name or cache properties (but only PROP_NAME property is allowed),

Returns

Cache object.

async get_cache_names() list

Gets existing cache names.

Returns

list of cache names.

get_cluster() pyignite.aio_cluster.AioCluster

Get client cluster facade.

Returns

AioCluster instance.

async get_or_create_cache(settings: Union[str, dict]) pyignite.aio_cache.AioCache

Creates Ignite cache, if not exist.

Parameters

settings – cache name or dict of cache properties’ codes and values. All cache properties are documented here: Cache Properties. See also the cache creation example,

Returns

Cache object.

async put_binary_type(type_name: str, affinity_key_field: str = None, is_enum=False, schema: dict = None)

Registers binary type information in cluster. Do not update binary registry. This is a literal implementation of Ignite thin client protocol’s OP_PUT_BINARY_TYPE operation. You would probably want to use register_binary_type() instead.

Parameters
  • type_name – name of the data type being registered,

  • affinity_key_field – (optional) name of the affinity key field,

  • is_enum – (optional) register enum if True, binary object otherwise. Defaults to False,

  • schema – (optional) when register enum, pass a dict of enumerated parameter names as keys and an integers as values. When register binary type, pass a dict of field names: field types. Binary type with no fields is OK.

async query_binary_type(binary_type: Union[int, str], schema: Optional[Union[int, dict]] = None)

Queries the registry of Complex object classes.

Parameters
  • binary_type – Complex object type name or ID,

  • schema – (optional) Complex object schema or schema ID,

Returns

found dataclass or None, if schema parameter is provided, a dict of {schema ID: dataclass} format otherwise.

async random_node() pyignite.connection.aio_connection.AioConnection

Returns random usable node.

This method is not a part of the public API. Unless you wish to extend the pyignite capabilities (with additional testing, logging, examining connections, et c.) you probably should not use it.

async register_binary_type(data_class: Type, affinity_key_field: Optional[str] = None)

Register the given class as a representation of a certain Complex object type. Discards autogenerated or previously registered class.

Parameters
  • data_class – Complex object class,

  • affinity_key_field – (optional) affinity parameter.

sql(query_str: str, page_size: int = 1024, query_args: Optional[Iterable] = None, schema: str = 'PUBLIC', statement_type: int = 0, distributed_joins: bool = False, local: bool = False, replicated_only: bool = False, enforce_join_order: bool = False, collocated: bool = False, lazy: bool = False, include_field_names: bool = False, max_rows: int = - 1, timeout: int = 0, cache: Optional[Union[int, str, pyignite.aio_cache.AioCache]] = None) pyignite.cursors.AioSqlFieldsCursor

Runs an SQL query and returns its result.

Parameters
  • query_str – SQL query string,

  • page_size – (optional) cursor page size. Default is 1024, which means that client makes one server call per 1024 rows,

  • query_args – (optional) query arguments. List of values or (value, type hint) tuples,

  • schema – (optional) schema for the query. Defaults to PUBLIC,

  • statement_type

    (optional) statement type. Can be:

    • StatementType.ALL − any type (default),

    • StatementType.SELECT − select,

    • StatementType.UPDATE − update.

  • distributed_joins – (optional) distributed joins. Defaults to False,

  • local – (optional) pass True if this query should be executed on local node only. Defaults to False,

  • replicated_only – (optional) whether query contains only replicated tables or not. Defaults to False,

  • enforce_join_order – (optional) enforce join order. Defaults to False,

  • collocated – (optional) whether your data is co-located or not. Defaults to False,

  • lazy – (optional) lazy query execution. Defaults to False,

  • include_field_names – (optional) include field names in result. Defaults to False,

  • max_rows – (optional) query-wide maximum of rows. Defaults to -1 (all rows),

  • timeout – (optional) non-negative timeout value in ms. Zero disables timeout (default),

  • cache – (optional) Name or ID of the cache to use to infer schema. If set, ‘schema’ argument is ignored,

Returns

async sql fields cursor with result rows as a lists. If include_field_names was set, the first row will hold field names.

tx_start(concurrency: pyignite.datatypes.transactions.TransactionConcurrency = TransactionConcurrency.PESSIMISTIC, isolation: pyignite.datatypes.transactions.TransactionIsolation = TransactionIsolation.REPEATABLE_READ, timeout: int = 0, label: Optional[str] = None) pyignite.transaction.AioTransaction

Start async thin client transaction. Supported only python 3.7+

Parameters
  • concurrency – (optional) transaction concurrency, see TransactionConcurrency,

  • isolation – (optional) transaction isolation level, see TransactionIsolation,

  • timeout – (optional) transaction timeout in milliseconds,

  • label – (optional) transaction label.

Returns

AioTransaction instance.

async unwrap_binary(value: Any) Any

Detects and recursively unwraps Binary Object.

Parameters

value – anything that could be a Binary Object,

Returns

the result of the Binary Object unwrapping with all other data left intact.