mercredi 9 septembre 2020

Does Observer Design Pattern suits for Email Box Monitoring based action

I am new in Design Pattern related concepts, I have to develop an app which will monitor an email box & if any new email/s comes, the app needs to execute few process and it will use the email data as an input for executions. This process can be sequential or parallel.

Eg. Email Box A receives an email E1. For this new Email E1 say, there are three operations needs to happen (down the line it can increase):

  1. Find the Category & Sub-categories (which will run a parallel thread to find both) for Ticket T1
  2. Create a ticket T1 in customer support app

I have one in mind but due to lack of comprehension which would be better approach I would like to seek your advice.

  1. Publish-Subscribe Pattern

  2. A simple logical programming:

    def execute():

     while True:
         email = emailbox.listen()
    
         if email.new_email > 0:
             content = email.content
             for e in email:
                category = Thread(target=find_category, args=(e,Q1))
                sub_category = Thread(target=find_sub_category, args=(e,Q2))
                category.start()
                category.join()
    
                sub_category.start()
                sub_category.join()
    
                cat = Q1.get()
                sub_cat = Q2.get()
    
                P1 = Create_email(e, cat, sub_cat)
    

Aucun commentaire:

Enregistrer un commentaire