python – Notification System Design

Class design feature for batch job system notification

I'm building a batch job executor (workflow automation system) in Python. The batch job is represented by an XML file, it contains a list of commands to execute, a cron scheduling and other configurations, such as configuration, to send a notification on success / failure of execution. a batch order.

See the examples below for a better understanding.

Static notification configuration


   
   
   
   name job1
   
      type mail
failure agrawall@amazon.com # This means sending an email notification to agrawalo if the command is executed.
stderr content
   
   
      
      
      
      echo hello loki
   
   calendar * / 20 * * * * * # Execute this job every 20 minutes

Dynamic notification conifiguration

def current_hour ():
"" "returns the current time as an integer" ""

def time_in_range (start, end, x):
"" "Returns true if x is in the range [start, end]"" "
if start <= end:
back to beginning <= x <= end
other:
return start <= x or x <= end  

 
   name job2
   
      type mail
      
          condition time_in_range (0, 11, current time ())
true agrawall@amazon.com # This means sending an email notification to agrawalo if the batch command fails to execute if the batch command fails between 0 and 11 o'clock in the day.
false mishrap@amazon.com # else send e-mail notification to mishrap
stderr content
      
   
   
      
      
      
      echo hello loki
   
   calendar * / 20 * * * * * # Execute this job every 20 minutes

To represent this XML code in python code, I created a class called BatchJob. BatchJob will contain notification_configuration as one of its properties. I want to create a class design to represent NotificationConfiguration that can contain dynamic notification configurations (with rule subtags – failure_rule, success_rule, and so on) and static (see the examples above for more details).

I'm looking for suggestions on class designs to represent the configuration of the notification.