shape method

List<DateTime> shape(
  1. List<DateTime> requested
)

Returns the admitted fire times for requested, in order. Each output is >= its corresponding request and respects the cooldown and window quota.

Example:

final RateLimitSchedule s = RateLimitSchedule(
  maxPerPeriod: 2,
  period: const Duration(hours: 1),
);
// Three requests at the same instant -> third slips to the next window.
s.shape(<DateTime>[t, t, t]); // [t, t, t + 1h]

Audited: 2026-06-12 11:26 EDT

Implementation

List<DateTime> shape(List<DateTime> requested) {
  final List<DateTime> admitted = <DateTime>[];
  for (final DateTime request in requested) {
    admitted.add(_admit(request, admitted));
  }
  return admitted;
}