Skip to content

Commit

Permalink
feat(low-code cdk): add interpolation for limit field in Rate (#353)
Browse files Browse the repository at this point in the history
Co-authored-by: octavia-squidington-iii <contact@airbyte.com>
  • Loading branch information
lazebnyi and octavia-squidington-iii authored Feb 20, 2025
1 parent ef0ca58 commit 665dc1f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
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

0 comments on commit 665dc1f

Please sign in to comment.