Skip to content

Rate limit improvements - #99

Merged
thoven87 merged 2 commits into
mainfrom
rate-limit-improvements
Oct 11, 2026
Merged

thoven87 merged 2 commits into
mainfrom
rate-limit-improvements

Conversation

@thoven87

@thoven87 thoven87 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

improved rate limit options

Changes

  • moved rate limit to its own file
  • added dynamic options

Testing

  • swift test passes locally

AI Disclosure

  • I used AI assistance while working on this PR

Tool(s) used:

Extent of use:

Was the PR description itself AI-generated?

Extend `RateLimit` with a `units` parameter (default `1`) so one dispatch can consume multiple tokens from a shared bucket. `slotParams` now scales `intervalMs` by `units`, and values are clamped to at least 1 to avoid invalid configuration.

Expanded tests cover pure `slotParams` behavior (base interval, scaling, key stability, clamping, per-key buckets) and an integration scenario proving a high-unit dispatch advances the shared bucket cursor by multiple slots.
Refactors `RateLimit` into its own file and extends it with `.keyed(...)` factories that derive per-entity keys from typed input via closures or KeyPaths. Enqueue paths now resolve dynamic keys while typed input is still available (`StrandClient` and `WorkflowContext`) before encoding/scheduling. Slot-key behavior was also clarified for `sharedKey` + `key` composition, and tests were expanded to cover dynamic key extraction, shared bucket partitioning, no-op resolution, and end-to-end per-entity bucket timing.
@thoven87
thoven87 merged commit f000dba into main Oct 11, 2026
4 of 5 checks passed
@thoven87
thoven87 deleted the rate-limit-improvements branch October 11, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant