NAME

Langertha::Skeid::Rate - The request rate of a policy: its shape, and whether one rate is within another

VERSION

version 0.005

DESCRIPTION

A request rate (skeid k125) is a mapping of per_s with its burst and/or per_min; see "Per-Key Routing Policy" in Langertha::Skeid. This module checks its shape, and -- for a rate that comes from a customer-source row (skeid k126) -- whether it stays within the rate of its policy.

normalize

my $rate = Langertha::Skeid::Rate->normalize($spec, $where);   # undef for none

The rate in its normalized form, { per_s, burst, per_min } with only the parts given; burst defaults to per_s rounded up. Croaks, naming $where, on anything else: not a mapping, an unknown field, a per_s or per_min not above 0, neither of them, a burst that is no whole number of at least 1, or a burst without per_s.

within

my $effective = Langertha::Skeid::Rate->within($row_spec, $ceiling);   # undef: looser

The rate a key gets when its own $row_spec (raw, as "normalize" takes it) may only tighten the normalized $ceiling of its policy (undef: no limit, so any rate is within it). Each part the ceiling has is kept, or replaced by a part of the row that is not above it; a part only the row has is added. A burst the row leaves out is the ceiling's burst when that is smaller than the default. Returns the effective normalized rate, or undef when the row asks for more than the ceiling allows anywhere. Croaks like "normalize" on a malformed row spec.

print

my $text = Langertha::Skeid::Rate->print($rate);   # '2/10/60', '' for none

A string that is equal for equal rates, for fingerprints and bucket resets.

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-skeid/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.