dry-monkey-93718
05/02/2022, 11:39 AM@delayed_router.post("/{restaurant}/make_dinner")
def make_dinner(restaurant: str, recipe: Recipe):
# Do a ton of work here.
Trigger them from anywhere:
make_dinner.delay(restaurant="Taj", recipe=Recipe(ingredients=["Pav","Bhaji"]))
helpful-mechanic-54614
05/03/2022, 9:21 AMdry-monkey-93718
05/03/2022, 9:24 AM.delay
schedules a http request with Google's CloudTasks.
delayed_router
is just a router with route_class
overriden.
Full-ish example: https://github.com/Adori/fastapi-cloud-tasks/blob/main/examples/simple/main.pydry-monkey-93718
05/03/2022, 9:42 AM