A simple but yet elegant publish/subscribe socket implementation using FastAPI Websocket.
Project description
FastAPI Pub/Sub
A simple but yet elegant publish/subscribe socket implementation using FastAPI Websocket.
Instalation
pip install fastapi-pubsub
How it works
FastAPI provides an awesome implementation of Websockets. But it can be painful to configure it to work as a publish/subscribe mechanism.
FastAPI Pub/Sub implemented a BaseWebSocket
that handles all client's connections under the hood. All you have to do is extend this class, overriding the method process(self, client)
with your desired logic.
A minimun example of a server/client communication can be seen here. Follow the instructions to see it working.
Contributing
Despite being full functional, this project is in a very early stage. Pull requests are very welcome!
In my opinion, a good next step here is to implement some in-memory database to store connections at connection_manager. For now, it uses a dictionary to handle it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fastapi_pubsub-0.0.3.tar.gz
.
File metadata
- Download URL: fastapi_pubsub-0.0.3.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9db4c93e8ab476f99b492f3211042dd023533f12bda4de4adad7a090bee1e580 |
|
MD5 | 39a60356b0d7b980bfcd7870ffcf8997 |
|
BLAKE2b-256 | bfaaea376148f5b4e1725dbb45ed189c97e5467637da82004b3f16494d8c8428 |
File details
Details for the file fastapi_pubsub-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: fastapi_pubsub-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84084ad40214d31f239eff988001665e282344c0da86b079ab4a2a8de16498d5 |
|
MD5 | ac59ea61d013a14cb710e13619e60787 |
|
BLAKE2b-256 | 66b9be0bf12d2da51d902e0c2cb0f55f317a91b75f9814ae72a4a503c2722526 |