Added ThrottleAt config

This commit is contained in:
Richard Frith-Macdonald 2020-10-09 15:27:10 +01:00
parent 8c36804950
commit 25061be0ea
2 changed files with 10 additions and 2 deletions

View file

@ -346,6 +346,10 @@
* <desc>A boolean saying whether a clear alert should supersede the
* original message or simply act as a new version with the same
* message identifier.</desc>
* <term>ThrottleAt</term>
* <desc>An integer in the range 1 to 3600 saying how many alerts may
* be sent to an <em>Other</em> destination per hour. Any configuration
* outside this range results in the default of 12 being used.</desc>
* </deflist>
*
* <p>When an EcAlerter instance is used by a Control server process,

View file

@ -36,6 +36,8 @@
#import "EcAlerter.h"
#import "NSFileHandle+Printf.h"
static uint32_t throttleAt = 12;
@interface EcAlertRegex: NSObject
{
NSRegularExpression *regex;
@ -123,8 +125,6 @@
@implementation EcAlertThrottle
static uint32_t throttleAt = 12;
- (NSString*) description
{
char buf[BUFSIZ];
@ -395,6 +395,10 @@ replaceFields(NSDictionary *fields, NSString *template)
- (BOOL) configureWithDefaults: (NSDictionary*)c
{
int i = [[c objectForKey: @"ThrottleAt"] intValue];
if (i <= 0 || i > 3600) i = 12;
throttleAt = i;
debug = [[c objectForKey: @"Debug"] boolValue];
quiet = [[c objectForKey: @"Quiet"] boolValue];
supersede = [[c objectForKey: @"Supersede"] boolValue];