Metadata-Version: 2.1
Name: uservice
Version: 0.1.1
Summary: A async microservice framework for python
Project-URL: Homepage, https://github.com/dahlkar/uservice
Author-email: Johan Dahlkar <johan.dahlkar@gmail.com>
License-Expression: MIT
Requires-Python: >=3.10
Requires-Dist: aio-pika>=9.0.7
Requires-Dist: click>=8.1.3
Requires-Dist: pydantic>=1.10.8
Requires-Dist: pyyaml>=6.0
Requires-Dist: uvloop>=0.17.0
Requires-Dist: watchfiles>=0.19.0
Provides-Extra: test
Requires-Dist: docker==6.1.3; extra == 'test'
Requires-Dist: pytest-asyncio==0.21.0; extra == 'test'
Requires-Dist: pytest==7.3.1; extra == 'test'
Description-Content-Type: text/markdown

# μService
A async microservice framework for Python. Inspired by [FastAPI](https://github.com/tiangolo/fastapi) and [Nameko](https://github.com/nameko/nameko).
It uses the [uvloop](https://github.com/MagicStack/uvloop) event loop instead of the default python asyncio loop.

## Requirements

Python 3.10+

## Example

``` python
from uservice import Service, EventPublisher, Depends
from typing import Annotated
from pydantic import BaseModel


class Payload(BaseModel):
    foo: int
    bar: str


publisher = EventPublisher()

service_a = Service(name="service_a")


@service_a.rpc()
def dispatch(
        input: Payload,
        publish: Annotated[Callable, Depends(publisher)],
):
    publish("event", payload)


service_b = Service(name="service_b")


@service_b.event_handler("service_a", "event")
def handle(
        payload: Payload,
):
    print(payload)
```
