Skip to content

Latest commit

 

History

History
37 lines (30 loc) · 1.57 KB

File metadata and controls

37 lines (30 loc) · 1.57 KB

Public API Constants and Aliases

This page documents small public values that are useful when validating configuration before constructing a limiter. Import them from token_throttle.

Constants

  • MAX_MODEL_FAMILY_LENGTH = 256: maximum normalized model_family length.
  • MAX_METRIC_LENGTH = 64: maximum metric name length.
  • MAX_ALIAS_LENGTH = 256: maximum model alias/name length accepted by public limiter inputs.
  • MAX_KEY_PREFIX_LENGTH = 128: maximum Redis key_prefix length.
  • MAX_RESERVATION_ID_LENGTH = 128: maximum reservation id length.
  • MAX_TOTAL_KEY_LENGTH = 8192: maximum Redis key length generated by the library.

All key-like strings are normalized to NFC and must be non-empty, printable, free of whitespace/control characters, and must not contain :, {, or }. Those characters are reserved for Redis key separators and Redis Cluster hash tags.

Type Aliases

  • MetricName = str: name of a metered resource, such as "requests" or "tokens".
  • PerSeconds = int: quota window length in seconds.
  • BucketId = tuple[MetricName, PerSeconds]: stable bucket identifier for one metric/window pair.
  • Usage = Mapping[MetricName, float]: mutable or immutable user-provided usage mapping.
  • FrozenUsage = frozendict[MetricName, float]: validated immutable usage snapshot used internally and in callbacks.
  • Capacities = frozendict[BucketId, float]: immutable capacity snapshot keyed by bucket id.

These aliases are descriptive API contracts rather than distinct runtime classes. Static analyzers should treat them as their expanded types.