From: John <jo...@to...> - 2012-11-29 02:23:37
|
What is the misterhouse pattern to throttle something like sending emails? I have a timer that once every 20 minutes triggers an action. In that action I am sending an email. For example: my $object = &::get_object_by_name('mechroom_water_detector'); $object->manage_heartbeat_timeout($xpl_timeout, \&report_xpl_offline, -1); sub report_xpl_offline { net_mail_send(to => 'my...@bl...v', subject => 'ALERT: Water detector is not online', text => 'AL ERT: Water detector is not online'); print_log "Water Detector is OFFLINE"; } I want to send that email at most once per day (for example). I am OK with case where sensor comes online and back offline in the same day (OK with only one email going out). One option was to save the time last email was sent and have logic based on that. I was just thinking there may be a construct for this kind of thing. John |