Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remi-hsbi/fastcc
Lightweight, efficient and developer-friendly framework for component communication
https://github.com/remi-hsbi/fastcc
aiomqtt asyncio framework iot mqtt python
Last synced: 4 days ago
JSON representation
Lightweight, efficient and developer-friendly framework for component communication
- Host: GitHub
- URL: https://github.com/remi-hsbi/fastcc
- Owner: ReMi-HSBI
- Created: 2025-01-30T10:20:19.000Z (7 days ago)
- Default Branch: main
- Last Pushed: 2025-01-30T12:29:42.000Z (7 days ago)
- Last Synced: 2025-01-30T13:27:44.988Z (7 days ago)
- Topics: aiomqtt, asyncio, framework, iot, mqtt, python
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
# FastCC
Framework for component communication with [MQTT](https://mqtt.org) and [Protocol Buffers](https://protobuf.dev) :boom:.
- Lightweight :zap:
- Efficient :rocket:
- Developer-friendly :technologist:This framework is built on top of [empicano](https://github.com/empicano)'s [aiomqtt](https://github.com/empicano/aiomqtt).
## Example
```python
import asyncio
import contextlib
import logging
import os
import sys
import typingimport aiomqtt
import fastccrouter = fastcc.CCRouter()
@router.route("example")
async def example(name: str, *, database: dict[str, typing.Any]) -> str:
database[name] = 1
print(database)
return f"Hello, {name}!"async def main() -> None:
logging.basicConfig(level=logging.INFO)database = {}
mqtt_client = aiomqtt.Client(
"test.mosquitto.org",
protocol=aiomqtt.ProtocolVersion.V5,
)
app = fastcc.FastCC(mqtt_client)
app.add_router(router)
app.add_injector(database=database)async with mqtt_client:
await app.run()# https://github.com/empicano/aiomqtt?tab=readme-ov-file#note-for-windows-users
if sys.platform.lower() == "win32" or os.name.lower() == "nt":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())with contextlib.suppress(KeyboardInterrupt):
asyncio.run(main())
```