pyignite.connection package

This module contains Connection class, that wraps TCP socket handling, as well as Ignite protocol handshaking.

class pyignite.connection.AioConnection(client: AioClient, host: str, port: int, username: str = None, password: str = None, **ssl_params)

Bases: pyignite.connection.connection.BaseConnection

Asyncio connection to Ignite node. It serves multiple purposes:

__init__(client: AioClient, host: str, port: int, username: str = None, password: str = None, **ssl_params)

Initialize connection.

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

Parameters
  • client – Ignite client object,

  • host – Ignite server node’s host name or IP,

  • port – Ignite server node’s port number,

  • 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()
property closed: bool

Tells if socket is closed.

async connect()

Connect to the given server node with protocol version fallback.

process_connection_lost(err, reconnect=False)
process_message(data)
async reconnect()
async request(query_id, data: Union[bytes, bytearray]) bytearray

Perform request. :param query_id: id of query. :param data: bytes to send.

class pyignite.connection.Connection(client: Client, host: str, port: int, username: str = None, password: str = None, timeout: float = None, handshake_timeout: float = 10.0, **ssl_params)

Bases: pyignite.connection.connection.BaseConnection

This is a pyignite class, that represents a connection to Ignite node. It serves multiple purposes:

__init__(client: Client, host: str, port: int, username: str = None, password: str = None, timeout: float = None, handshake_timeout: float = 10.0, **ssl_params)

Initialize connection.

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

Parameters
  • client – Ignite client object,

  • host – Ignite server node’s host name or IP,

  • port – Ignite server node’s port number,

  • timeout – (optional) sets timeout (in seconds) for each socket operation including connect. 0 means non-blocking mode, which is virtually guaranteed to fail. Can accept integer or float value. Default is None (blocking mode),

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

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

close(on_reconnect=False)

Try to mark socket closed, then unlink it. This is recommended but not required, since sockets are automatically closed when garbage-collected.

property closed: bool

Tells if socket is closed.

connect()

Connect to the given server node with protocol version fallback.

reconnect()
recv(flags=None, reconnect=True) bytearray

Receive data from the socket.

Parameters
  • flags – (optional) OS-specific flags.

  • reconnect – (optional) reconnect on failure, default True.

request(data: Union[bytes, bytearray], flags=None) bytearray

Perform request.

Parameters
  • data – bytes to send,

  • flags – (optional) OS-specific flags.

send(data: Union[bytes, bytearray], flags=None, reconnect=True)

Send data down the socket.

Parameters
  • data – bytes to send,

  • flags – (optional) OS-specific flags.

  • reconnect – (optional) reconnect on failure, default True.

Submodules