Skip to content

Commit 1f7dee0

Browse files
authored
Merge pull request #34 from python-ellar/ellar_070
Ellar 0.7.0 support
2 parents 9428fd4 + 4e7eebd commit 1f7dee0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

ellar_throttler/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""A rate limiting module for Ellar"""
22

3-
__version__ = "0.1.0"
3+
__version__ = "0.1.2"
44

55
from .decorators import skip_throttle, throttle
66
from .exception import ThrottledException

ellar_throttler/throttler_guard.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import typing as t
33

44
from ellar.common import GuardCanActivate, IExecutionContext, Response
5-
from ellar.common.utils import get_name
65
from ellar.core.connection import HTTPConnection
76
from ellar.core.services import Reflector
87
from ellar.di import injectable
8+
from ellar.utils import get_name
99

1010
from .constants import THROTTLER_LIMIT, THROTTLER_SKIP, THROTTLER_TTL
1111
from .exception import ThrottledException
@@ -60,8 +60,10 @@ def get_request_response(
6060
return connection_host.get_client(), connection_host.get_response()
6161

6262
def get_tracker(self, connection: HTTPConnection) -> str:
63-
assert connection.client
64-
return connection.client.host
63+
if connection.client:
64+
return connection.client.host
65+
66+
return t.cast(str, connection.scope["server"][0])
6567

6668
def generate_key(self, context: IExecutionContext, suffix: str) -> str:
6769
prefix = f"{get_name(context.get_class())}-{get_name(context.get_handler())}"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ classifiers = [
4040
]
4141

4242
dependencies = [
43-
"ellar >= 0.5.8"
43+
"ellar >= 0.7.0"
4444
]
4545

4646

0 commit comments

Comments
 (0)