Integration package for Dishka DI and Jobify framework
Project description
Jobify integration for Dishka
Though it is not required, you can use dishka-jobify integration. It features:
- REQUEST scope management using jobify request scope
- JobifyProvider for working with
JobContext,Job,State,RequestState,Runnablein container
You need to specify @inject manually.
Installation
Install using pip
pip install dishka-jobify
Or with uv
uv add dishka-jobify
How to use
- Import
from dishka_jobify import (
FromDishka,
inject,
setup_dishka
)
from dishka import make_async_container, Provider, provide, Scope
- Create provider like here below
class MyProvider(Provider):
@provide(scope=Scope.REQUEST)
def get_greeting_service(self) -> GreetingService:
return GreetingService(name="Dishka User")
@provide(scope=Scope.APP)
def get_counter_service(self) -> CounterService:
return CounterService()
- Mark those of your handlers parameters which are to be injected with
FromDishka[]
@app.task
@inject
async def my_cron(
greeting: FromDishka[GreetingService],
counter: FromDishka[CounterService],
) -> None:
count = counter.increment()
print(f"[cron] {greeting.greet('cron')} count={count}")
- Setup
dishkaintegration.
UTC = ZoneInfo("UTC")
app = Jobify(tz=UTC)
provider = MyProvider()
container = make_async_container(provider, JobifyProvider())
setup_dishka(container=container, app=app)
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
dishka_jobify-0.0.1.tar.gz
(122.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dishka_jobify-0.0.1.tar.gz.
File metadata
- Download URL: dishka_jobify-0.0.1.tar.gz
- Upload date:
- Size: 122.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cebcc19f5fe0dff602875dcd1a80444eabf43bb59d48334f49f822db9fac9ec
|
|
| MD5 |
2cce45ccd4cecf9c5fb021d27cd9a305
|
|
| BLAKE2b-256 |
20d08a6d7d18ccd7cb7ce7b9f58622103aee6778aa31cef939f942395815799c
|
File details
Details for the file dishka_jobify-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dishka_jobify-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01ff29c7061128be24d331b1a15dc798cc1262a5caa52a5d5311c12b4dfcce4c
|
|
| MD5 |
027788b64b7df8b1d9c8d1a3e9f868b6
|
|
| BLAKE2b-256 |
c3c0ac6cb4de9e5a1296a4254f76d87f50e134a4e0177a67c31eed6f0e85e89f
|