mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
docs
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import sqlite3
|
||||
from sqlite3 import Connection
|
||||
from typing import Iterable
|
||||
|
||||
from dishka import Provider, Scope, provide
|
||||
|
||||
from argenta import App, Orchestrator
|
||||
|
||||
|
||||
class ConnectionProvider(Provider):
|
||||
@provide(scope=Scope.REQUEST)
|
||||
def new_connection(self) -> Iterable[Connection]:
|
||||
conn = sqlite3.connect(":memory:")
|
||||
yield conn
|
||||
conn.close()
|
||||
|
||||
# 2. Создаем и настраиваем App
|
||||
app = App()
|
||||
# ... здесь можно добавить роутеры ...
|
||||
|
||||
# 3. Создаем Orchestrator, передавая наш провайдер
|
||||
orchestrator = Orchestrator(custom_providers=[ConnectionProvider()])
|
||||
|
||||
# 4. Запускаем приложение
|
||||
if __name__ == "__main__":
|
||||
orchestrator.start_polling(app)
|
||||
Reference in New Issue
Block a user