Skip to main content

⛓️ Combination of asyncapi(documentation) & socketio pub/sub using aiokafka as the client manager multinode backend services

Project description

Sample image

aiosox: repo link

Quick example

can be installed using pip/poetry:

poetry shell
 
poetry run uvicorn example:app --port=8001
from typing import List

from fastapi import FastAPI
from pydantic import BaseModel

from aiosox import SioAuth, SioNamespace, SocketIoServer


def get_app():
    applitcation = FastAPI(title="tester")
    return applitcation


app = get_app()

sio_server: SocketIoServer = SocketIoServer(app=app, kafka_url="localhost:29092")
user_namespapce: SioNamespace = SioNamespace("/user", socket_io_server=sio_server)
sio_server._sio.register_namespace(user_namespapce)


@app.on_event("startup")
async def on_start():
    await sio_server.start()


@app.on_event("shutdown")
async def on_shutdown():
    await sio_server.shutdown()


class UserY(BaseModel):
    name: str


class UserT(BaseModel):
    name: str
    what: List[UserY]


class OfferT(BaseModel):
    title: str


on_failed_emmiter = user_namespapce.create_emitter("failed", model=OfferT | UserT)


@user_namespapce.on(
    "submit",
    description="when user submits a form",
    payload_model=UserT | UserY,
    response_model=List[UserT],
    auth=SioAuth.jwt,
)
async def on_submit(sid, data):
    print(
        sid,
        data,
    )

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

aiosox-0.3.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

aiosox-0.3.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file aiosox-0.3.0.tar.gz.

File metadata

  • Download URL: aiosox-0.3.0.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.0 Darwin/22.1.0

File hashes

Hashes for aiosox-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3ec444bd9e09ca392b9fafb3af5b4f3caeb4e58cef1ef297e710f5a84fab5a83
MD5 65fae746b325cf9ea0212bb7e2f8c683
BLAKE2b-256 53662fdbc5fafa73d399d80e2df4357831ff5534781b42e2c340d56baa0835c3

See more details on using hashes here.

File details

Details for the file aiosox-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: aiosox-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.0 Darwin/22.1.0

File hashes

Hashes for aiosox-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ed8afe9d20dcf7796f2d55f29a3be0d686a78ede239a25dc324f2f322378211
MD5 a925fc064d176779de52a8a5c079d7f1
BLAKE2b-256 766ab58d18b1fb8f8f796aef9fc2cc93757ccc068fa9d62aace2b3275dbc115f

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