jbostoen / itop-jb-mail-to-ticket-automation-v2

Originally a fork of Combodo's Mail to Ticket Automation, enriched with some new features. Also contains some bug fixes.
https://jeffreybostoen.be
6 stars 3 forks source link

Refactor code: steps vs policies #11

Closed jbostoen closed 1 year ago

jbostoen commented 2 years ago

There could be a more clear distinction between a processing step and policies.

Right now, every 'step' in the e-mail processing is called a 'policy'.

It would make more sense to have these definitions:

Initially some backward compatibility methods may need to be added. Also the $iPrecedence order would be shared, which further advocates the idea of policies being a subclass of a step; where some assumptions may be made by default instead (although "behavior" is often present, "bounce subject" and "bounce message" are not. Consider whether this should also be a subclass of a policy)

Alternatively, there could be an interface iStep which replaces iPolicy; and two abstract classes to extend (one being Step and one being Policy, possibly a subclass of Step).

jbostoen commented 1 year ago

The new idea is simplification. A lot of steps are added, which aren't enforcing anything (so not really a "policy").

A step would also have a rank and be able to by default print some input before and after execution. Some methods would need to be renamed though.

A policy would be the same as a step, but on top of that it could block further processing of the e-mail.

There's no functional benefit for now to start working on this.

jbostoen commented 1 year ago

Functional benefit: in some scenarios, steps can be performed (e.g. create IMAP folder) which take a bit of time to properly synchronize. This could indeed be queued and so on, but indefinitely queueing risks breaking the mail processing and causing it to hang.

It would be nice if there could be some attempts, after which the processing continues; and just keeps the e-mail as unprocessed (so it's attempted again next time) rather than assigning another unwanted status to it.

A sort of "timeout" would also be nice to have.

jbostoen commented 1 year ago

Another point to consider: a step should be able to completely suspend the ongoing e-mail processing.

Use case: in the first run, a step may perform an action which takes some time (e.g. create new mail folder, call an API, ...) which takes some time to finish. Rather than implementing a wait; in some cases it may be best to abandon the current execution of mail processing altogether.