-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Differently from a concurrency or a rate limit, sometime we just need to debounce rapidly-fired off tasks and totally skip them. I think it could look something like this:
async def send_alert(debounce = Debounce(cooldown=timedelta(seconds=30))):
...Perhaps like concurrency limiting, though, it should have some intra-key awareness, so:
async def send_alert(
customer_id: UUID,
debounce = Debounce("customer_id", cooldown=timedelta(seconds=30))
):
...But here's where I wish we had explored Annotated for this in Concurrency and maybe we can do that here:
async def send_alert(
customer_id: Annotated[UUID, Debounce(cooldown=timedelta(seconds=30))]
):
...Regardless of how we define it, the behavior would be tied in with the worker's admission control to skip this work (and to log that we are skipping it). Not sure if this needs new support in the worker or if we can do it with the hooks we have, but it should be a fairly lightweight addition and would support other future hypothetical dependencies.
Inspired by some work @zangell44 is doing on Prefect Cloud.