Skip to content

feat(low-code cdk): add interpolation for limit field in Rate #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,11 @@ definitions:
limit:
title: Limit
description: The maximum number of calls allowed within the interval.
type: integer
anyOf:
- type: integer
- type: string
interpolation_context:
- config
interval:
title: Interval
description: The time interval for the rate limit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ class Rate(BaseModel):
class Config:
extra = Extra.allow

limit: int = Field(
limit: Union[int, str] = Field(
...,
description="The maximum number of calls allowed within the interval.",
title="Limit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3024,8 +3024,9 @@ def create_unlimited_call_rate_policy(
)

def create_rate(self, model: RateModel, config: Config, **kwargs: Any) -> Rate:
interpolated_limit = InterpolatedString.create(str(model.limit), parameters={})
return Rate(
limit=model.limit,
limit=int(interpolated_limit.eval(config=config)),
interval=parse_duration(model.interval),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ def test_backoff_strategy_from_manifest_is_respected(http_requester_factory: Any
)


def test_http_requester_with_mock_apibudget(http_requester_factory, monkeypatch):
def test_http_requester_with_mock_api_budget(http_requester_factory, monkeypatch):
mock_budget = MagicMock(spec=HttpAPIBudget)

requester = http_requester_factory(
Expand Down
Loading