diff --git a/EcAlerter.h b/EcAlerter.h index e6e3d22..ce73607 100644 --- a/EcAlerter.h +++ b/EcAlerter.h @@ -346,6 +346,10 @@ * A boolean saying whether a clear alert should supersede the * original message or simply act as a new version with the same * message identifier. + * ThrottleAt + * An integer in the range 1 to 3600 saying how many alerts may + * be sent to an Other destination per hour. Any configuration + * outside this range results in the default of 12 being used. * * *

When an EcAlerter instance is used by a Control server process, diff --git a/EcAlerter.m b/EcAlerter.m index 9fa9011..c47cae4 100644 --- a/EcAlerter.m +++ b/EcAlerter.m @@ -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];