Welcome to Asynction’s documentation!

Asynction SocketIO Server

The AsynctionSocketIO server is essentially a flask_socketio.SocketIO server with an additional factory classmethod.

class asynction.AsynctionSocketIO(spec: asynction.types.AsyncApiSpec, validation: bool = True, app: Optional[flask.app.Flask] = None, **kwargs)
classmethod from_spec(spec_path: pathlib.Path, validation: bool = True, server_name: Optional[str] = None, default_error_handler: Optional[Callable[[Exception], None]] = None, app: Optional[flask.app.Flask] = None, **kwargs)flask_socketio.SocketIO

Create a Flask-SocketIO server from an AsyncAPI spec. This is the single entrypoint to the Asynction API.

Parameters
  • spec_path – The path where the AsyncAPI YAML specification is located.

  • validation – When set to False, message payloads and channel bindings are NOT validated. Defaults to True.

  • server_name – The server to pick from the Async API servers object. The server object is then used to configure the path kwarg of the SocketIO server.

  • default_error_handler – The error handler that handles any namespace without an explicit error handler. Equivelant of @socketio.on_error_default

  • app – The flask application instance. Defaults to None.

  • kwargs – Flask-SocketIO, Socket.IO and Engine.IO server options.

Returns

A Flask-SocketIO server. The server has all the event and error handlers registered.

Example:

asio = AsynctionSocketIO.from_spec(
    spec_path="./docs/asyncapi.yaml",
    app=flask_app,
    message_queue="redis://localhost:6379",
    # any other kwarg that the flask_socketio.SocketIO constructor accepts
)

Exceptions

Asynction’s exceptions to be caught via Flask-SocketIO error handlers.

exception asynction.AsynctionException

The base class for all asynction runtime exceptions.

exception asynction.ValidationException

The base class for all asynction validation exceptions.

exception asynction.PayloadValidationException

Raised when the payload of an incoming or outgoing message fails the schema validation.

exception asynction.BindingsValidationException

Raised when the HTTP bindings of an incoming connection fail the schema validation.

exception asynction.MessageAckValidationException

Raised when the input arguments passed to the ack callback do not adhere to the x-ack args schema.

Indices and tables