aea.connections.base

The base connection package.

ConnectionStatus

class ConnectionStatus()

The connection status class.

__init__

 | __init__()

Initialize the connection status.

Connection

class Connection(Component,  ABC)

Abstract definition of a connection.

__init__

 | __init__(configuration: Optional[ConnectionConfig] = None, address: Optional["Address"] = None, restricted_to_protocols: Optional[Set[PublicId]] = None, excluded_protocols: Optional[Set[PublicId]] = None, connection_id: Optional[PublicId] = None)

Initialize the connection.

The configuration must be specified if and only if the following parameters are None: connection_id, excluded_protocols or restricted_to_protocols.

Arguments:

  • configuration: the connection configuration.
  • address: the address.
  • restricted_to_protocols: the set of protocols ids of the only supported protocols for this connection.
  • excluded_protocols: the set of protocols ids that we want to exclude for this connection.
  • connection_id: the connection identifier.

loop

 | @loop.setter
 | loop(loop: AbstractEventLoop) -> None

Set the event loop.

Arguments:

  • loop: the event loop.

Returns:

None

address

 | @address.setter
 | address(address: "Address") -> None

Set the address to be used by the connection.

Arguments:

  • address: a public key.

Returns:

None

component_type

 | @property
 | component_type() -> ComponentType

Get the component type.

connection_id

 | @property
 | connection_id() -> PublicId

Get the id of the connection.

configuration

 | @property
 | configuration() -> ConnectionConfig

Get the connection configuration.

excluded_protocols

 | @property
 | excluded_protocols() -> Set[PublicId]

Get the ids of the excluded protocols for this connection.

connection_status

 | @property
 | connection_status() -> ConnectionStatus

Get the connection status.

connect

 | @abstractmethod
 | async connect()

Set up the connection.

disconnect

 | @abstractmethod
 | async disconnect()

Tear down the connection.

send

 | @abstractmethod
 | async send(envelope: "Envelope") -> None

Send an envelope.

Arguments:

  • envelope: the envelope to send.

Returns:

None

receive

 | @abstractmethod
 | async receive(*args, **kwargs) -> Optional["Envelope"]

Receive an envelope.

Returns:

the received envelope, or None if an error occurred.

from_config

 | @classmethod
 | from_config(cls, address: "Address", configuration: ConnectionConfig) -> "Connection"

Initialize a connection instance from a configuration.

Arguments:

  • address: the address of the agent.
  • configuration: the connection configuration.

Returns:

an instance of the concrete connection class.