The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Bot::Backbone::SendPolicy::MinimumInterval - Prevent any message from being delivered too soon

VERSION

version 0.161950

SYNOPSIS

  send_policy no_flooding => (
      MinimumInterval => { 
          interval     => 1.5,
          discard      => 1,
          queue_length => 5,
      },
  );

DESCRIPTION

This send policy will prevent any message from being sent more frequently than the permitted "interval". Messages sent more frequently than this will either be delayed to match the interval or discarded.

ATTRIBUTES

interval

This is the fractional number of seconds that must pass between each message sent. This attribute is required. The number must be positive (obviously).

queue_length

This is the number of items that will be queued up before additional items will be discarded.

For example, if "interval" were set to 1 second and queue_length to 10 and a burst of 100 items happened within 1 second, only the first 10 would be sent, 1 per second. The other 90 items would be discarded. There's a slight fudge factor here due to times, so you might see a few more actually sent depending on how much delay happens in handling events.

If "discard" is set to false, it is recommended that you set this value to something reasonable.

discard

If set to true, any message sent more frequently than the "interval" will be immediately discarded. This is false by default.

last_send_time

This will be set each time the policy encounters a message. If "discard" is false, this value may move into the future to signify the time at which the last queued message will be sent.

METHODS

allow_send

Applies the configured policy to the given message.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Qubling Software LLC.

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