From 017b3c30eec1b25ed1937bd0497714a021e17860 Mon Sep 17 00:00:00 2001 From: Tony Holdstock-Brown <tonyhb@gmail.com> Date: Wed, 28 Aug 2024 10:16:23 +0100 Subject: [PATCH] Change throttling count to limit (#148) * Change throttling count to limit * Add burst to throttling * Fix tests * Update versions --------- Co-authored-by: Aaron Harper <aaron@inngest.com> --- inngest/_internal/comm_lib/handler_test.py | 2 +- inngest/_internal/const.py | 2 +- inngest/_internal/server_lib/registration.py | 3 ++- inngest/_internal/server_lib/registration_test.py | 5 +++-- pyproject.toml | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/inngest/_internal/comm_lib/handler_test.py b/inngest/_internal/comm_lib/handler_test.py index 438999a3..63f66887 100644 --- a/inngest/_internal/comm_lib/handler_test.py +++ b/inngest/_internal/comm_lib/handler_test.py @@ -46,7 +46,7 @@ def test_full_config(self) -> None: name="Function", retries=1, throttle=inngest.Throttle( - count=2, period=datetime.timedelta(minutes=1) + limit=2, period=datetime.timedelta(minutes=1) ), trigger=inngest.TriggerEvent(event="app/fn"), ) diff --git a/inngest/_internal/const.py b/inngest/_internal/const.py index e2ce0280..50927cbd 100644 --- a/inngest/_internal/const.py +++ b/inngest/_internal/const.py @@ -5,7 +5,7 @@ DEFAULT_EVENT_API_ORIGIN: typing.Final = "https://inn.gs/" DEV_SERVER_ORIGIN: typing.Final = "http://127.0.0.1:8288/" LANGUAGE: typing.Final = "py" -VERSION: typing.Final = "0.4.11" +VERSION: typing.Final = "0.4.12" class EnvKey(enum.Enum): diff --git a/inngest/_internal/server_lib/registration.py b/inngest/_internal/server_lib/registration.py index ea896f1c..a0160d2d 100644 --- a/inngest/_internal/server_lib/registration.py +++ b/inngest/_internal/server_lib/registration.py @@ -139,8 +139,9 @@ class Step(_BaseConfig): class Throttle(_BaseConfig): key: typing.Optional[str] = None - count: int + limit: int period: typing.Union[int, datetime.timedelta] + burst: typing.Optional[int] = 1 @pydantic.field_serializer("period") def serialize_period( diff --git a/inngest/_internal/server_lib/registration_test.py b/inngest/_internal/server_lib/registration_test.py index 772cb055..7de8cbf6 100644 --- a/inngest/_internal/server_lib/registration_test.py +++ b/inngest/_internal/server_lib/registration_test.py @@ -63,7 +63,7 @@ def test_serialization() -> None: ), throttle=Throttle( key="foo", - count=1, + limit=1, period=datetime.timedelta(seconds=60), ), triggers=[ @@ -122,7 +122,8 @@ def test_serialization() -> None: }, "throttle": { "key": "foo", - "count": 1, + "limit": 1, + "burst": 1, "period": "1m", }, "triggers": [ diff --git a/pyproject.toml b/pyproject.toml index b4ccf78c..98858e20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "inngest" -version = "0.4.11" +version = "0.4.12" description = "Python SDK for Inngest" readme = "README.md" classifiers = [