Skip to content

Commit

Permalink
Change throttling count to limit (#148)
Browse files Browse the repository at this point in the history
* Change throttling count to limit

* Add burst to throttling

* Fix tests

* Update versions

---------

Co-authored-by: Aaron Harper <aaron@inngest.com>
  • Loading branch information
tonyhb and amh4r authored Aug 28, 2024
1 parent 71fe456 commit 017b3c3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion inngest/_internal/comm_lib/handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
Expand Down
2 changes: 1 addition & 1 deletion inngest/_internal/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion inngest/_internal/server_lib/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions inngest/_internal/server_lib/registration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_serialization() -> None:
),
throttle=Throttle(
key="foo",
count=1,
limit=1,
period=datetime.timedelta(seconds=60),
),
triggers=[
Expand Down Expand Up @@ -122,7 +122,8 @@ def test_serialization() -> None:
},
"throttle": {
"key": "foo",
"count": 1,
"limit": 1,
"burst": 1,
"period": "1m",
},
"triggers": [
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "inngest"
version = "0.4.11"
version = "0.4.12"
description = "Python SDK for Inngest"
readme = "README.md"
classifiers = [
Expand Down

0 comments on commit 017b3c3

Please sign in to comment.