Connection

This script defines the Connection abstract base class, which specifies the common interface implemented by every way this SDK can talk to Ankaios (the control interface, used from inside a workload, or a direct gRPC connection to the Ankaios server, used from outside a workload).

Classes

  • Connection:

    Abstract base class for a connection to Ankaios.

Enums

  • ConnectionType:

    Represents which connection the Ankaios class should use.

Connection Class

class ankaios_sdk._components.connection.connection.Connection(add_response_callback, add_log_callback, add_event_callback)[source]

Bases: ABC

Abstract base class that defines the common interface for every connection to Ankaios, so that the Ankaios class can work identically regardless of which connection implementation is used.

__init__(add_response_callback, add_log_callback, add_event_callback)[source]

Stores the callbacks shared by every connection implementation for forwarding responses, logs and events to the Ankaios class.

Parameters:
  • add_response_callback (Callable) – The callback function to add a response to the Ankaios class.

  • add_log_callback (Callable) – The callback function to add a log to the Ankaios class.

  • add_event_callback (Callable) – The callback function to add an event to the Ankaios class.

abstract property connected: bool

Check if the connection is established.

Returns:

True if connected, False otherwise.

Return type:

bool

abstract connect()[source]

Establish the connection.

Return type:

None

abstract disconnect()[source]

Tear down the connection.

Return type:

None

abstract write_request(request)[source]

Send a request through the connection.

Parameters:

request (Request) – The request object to be sent.

Return type:

None

ConnectionType Enum

class ankaios_sdk._components.connection.connection.ConnectionType(value)[source]

Bases: Enum

Represents which connection the Ankaios class should use.

CONTROL_INTERFACE = 1

Connect via the control interface (named pipes).

Type:

(int)

COMMAND_INTERFACE = 2

Connect via the command interface (direct gRPC).

Type:

(int)

__str__()[source]

Returns the string representation of the connection type.

Returns:

The connection type as a string.

Return type:

str