Notification System Design

by Lokesh Agrawal   Last Updated May 16, 2019 02:05 AM

Class Design for Notification feature of Batch Job Execution System

I am building a Batch Job executor (workflow automation system) in Python. Batch Job is represented by an XML file, it has a list of commands to be executed, cron schedule and other configurations like configuration to send notification on success/failure of batch command execution.

Check examples below for better understanding.

Static notification configuration

<job>
   name job1
   <notify>
      type mail
      failure [email protected] # this means send email notification to agrawalo on failure of command execution.
   </notify>
   <command>
      echo hello loki
   </command>
   schedule * 2 * * *
</job>

Dynamic notification conifiguration

def time_in_range(start, end, x):
   """Return true if x is in the range [start, end]"""
    if start <= end:
       return start <= x <= end
   else:
       return start <= x or x <= end  

<job> 
   name job2
   <notify>
      type mail
      <failure_rule>
          condition time_in_range(0, 11, currenthour())
          true [email protected] # this means send email notification to agrawalo on failure of batch command execution if the batch command fails in 0 to 11th hours of a day.
          false [email protected] # else send email notification to mishrap
      </failure_rule>
   </notify>
   <command>
      echo hello loki
   </command>
   schedule * 2 * * *
</job>

To represent this XML in python code, I have created a class called BatchJob. BatchJob will contain notification_configuration as one of its property. I want to create a class design for representing NotificationConfiguration that can hold dynamic (with rule subtag) and static notification configurations (check the examples above for details).

I am looking for suggestions around class designs for representing Notification configuration.



Related Questions


Updated August 06, 2015 14:02 PM

Updated January 17, 2018 16:05 PM

Updated September 23, 2016 09:02 AM

Updated March 01, 2018 14:05 PM