You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The CLI -l flag only supports per-minute limits with name:capacity syntax (e.g., -l tpm:10000). Users who need per-second, per-hour, or per-day limits must use the Python API directly — there is no way to express non-minute periods through the CLI. This forces a round trip to code for what should be a simple administrative operation.
Proposed Solution
Extend the -l flag to accept an optional /period suffix: name:rate[/period][:burst]. Period defaults to /min when omitted, preserving full backward compatibility.
Supported period syntax
Suffix
Period
Example
/sec
1 second
-l rps:50/sec
/min
1 minute (default)
-l rpm:1000 or -l rpm:1000/min
/hour
1 hour
-l tph:100000/hour
/day
1 day
-l rpd:1000000/day
/Nunit
N × unit
-l rpm:100/5min (= 300 seconds)
With burst
Burst remains the third colon-separated field, after the rate/period component:
_parse_limit("tph:100000/hour:150000") sets capacity=150000 and refill_amount=100000 (burst with period)
_parse_limit("rpm:100/week") raises click.BadParameter with "Invalid period" message
_format_limit() displays period suffix (e.g., tph: 100,000/hour) instead of hardcoded /min
_format_limit() appends (burst: N) when capacity != refill_amount
-l help text on all three commands reads 'name:rate[/period][:burst]' with period options listed
CLI examples updated to demonstrate period syntax in resource set-defaults, system set-defaults, and entity set-limits
Unit tests cover all period units (/sec, /min, /hour, /day), multiplied periods (/5min), burst with period, and invalid periods
Alternatives Considered
Separate --period flag: Rejected because it couples awkwardly with multiple -l flags (which limit gets which period?). Inline syntax keeps rate and period together.
Use ISO 8601 duration (PT1H): Overly verbose for CLI usage. /hour is more intuitive for the target audience (ops/platform engineers).
Problem or Use Case
The CLI
-lflag only supports per-minute limits withname:capacitysyntax (e.g.,-l tpm:10000). Users who need per-second, per-hour, or per-day limits must use the Python API directly — there is no way to express non-minute periods through the CLI. This forces a round trip to code for what should be a simple administrative operation.Proposed Solution
Extend the
-lflag to accept an optional/periodsuffix:name:rate[/period][:burst]. Period defaults to/minwhen omitted, preserving full backward compatibility.Supported period syntax
/sec-l rps:50/sec/min-l rpm:1000or-l rpm:1000/min/hour-l tph:100000/hour/day-l rpd:1000000/day/Nunit-l rpm:100/5min(= 300 seconds)With burst
Burst remains the third colon-separated field, after the rate/period component:
New helper functions
_parse_period(period_str)— parses5min,hour,2dayinto seconds_format_period(seconds)— formats seconds back to the most natural unit suffix_parse_limit()— updated to split rate from period suffix before parsing_format_limit()— updated to displayrefill_amountwith period suffix, and(burst: N)when capacity differs from refill_amountDisplay format
Affected CLI commands
All commands that accept the
-lflag are updated with the new help text and examples:zae-limiter resource set-defaultszae-limiter system set-defaultszae-limiter entity set-limitsAcceptance Criteria
_parse_limit("rps:50/sec")returns aLimitwithrefill_period_seconds=1andrefill_amount=50_parse_limit("tph:100000/hour")returns aLimitwithrefill_period_seconds=3600_parse_limit("rpd:1000000/day")returns aLimitwithrefill_period_seconds=86400_parse_limit("tpm:10000/min")is equivalent to_parse_limit("tpm:10000")(backward compatible)_parse_limit("rpm:100/5min")returnsrefill_period_seconds=300(multiplied periods)_parse_limit("tph:100000/hour:150000")setscapacity=150000andrefill_amount=100000(burst with period)_parse_limit("rpm:100/week")raisesclick.BadParameterwith "Invalid period" message_format_limit()displays period suffix (e.g.,tph: 100,000/hour) instead of hardcoded/min_format_limit()appends(burst: N)whencapacity != refill_amount-lhelp text on all three commands reads'name:rate[/period][:burst]'with period options listedresource set-defaults,system set-defaults, andentity set-limits/sec,/min,/hour,/day), multiplied periods (/5min), burst with period, and invalid periodsAlternatives Considered
Separate
--periodflag: Rejected because it couples awkwardly with multiple-lflags (which limit gets which period?). Inline syntax keeps rate and period together.Use ISO 8601 duration (PT1H): Overly verbose for CLI usage.
/houris more intuitive for the target audience (ops/platform engineers).