Skip to main content

SocketIO framework driven by the AsyncAPI specification. Built on top of Flask-SocketIO. Inspired by Connexion.

Project description

Asynction

Tests Status

SocketIO python framework driven by the AsyncAPI specification. Built on top of Flask-SocketIO. Inspired by Connexion.

The purpose of asynction is to empower a specification first approach when developing SocketIO APIs in Python.

Disclaimer: Asynction is still at a very early stage and should not be used in production codebases.

Prerequisites

  • Python 3.7 (or higher)

Install

$ pip install asynction

Usage

Example event handler callable sitting under ./my_api/handlers.py:

def user_signedup():
    logger.info("Registered user")

Example specification sitting under ./docs/asyncapi.yaml:

asyncapi: 2.0.0
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  user/signedup:
    subscribe:
      operationId: my_api.handlers.user_signedup
      message:
        $ref: '#/components/messages/UserSignedUp'
components:
  messages:
    UserSignedUp:
      payload:
        type: object

Bootstrap the AsynctionSocketIO server:

from asynction import AsynctionSocketIO
from flask import Flask

flask_app = Flask(__name__)

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

The AsynctionSocketIO class extends the SocketIO class of the Flask-SocketIO library.
The above asio server object is ready be run without the need to register the event handlers.

TODOs

  1. on_error handlers
  2. Increase JSON Schema reference resolution test coverage
  3. Payload validation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asynction-0.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

asynction-0.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file asynction-0.0.1.tar.gz.

File metadata

  • Download URL: asynction-0.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.0

File hashes

Hashes for asynction-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8eed0ce8b0c5acd2c2d86c40db800dd60d1222c5095f3998778c0c2606a57933
MD5 8b9312ba2b594df9c23fd6200c4f6a6b
BLAKE2b-256 e8920d1590e1fdec38a11582c35291dadaadf0d8a2fb9f8e0ad2f2ec1da06c06

See more details on using hashes here.

File details

Details for the file asynction-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: asynction-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.0

File hashes

Hashes for asynction-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4667dca7dbda8a4a8c299b7da1a6dd48a107c10262b7521bc26109efe36b0c97
MD5 65d0c7019e11ff0f7821573cb4934b54
BLAKE2b-256 cf052c1a56640cc0f82e95d376434c79ba76971862e614c9b58d0b1a49b79113

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page