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.