serge icon indicating copy to clipboard operation
serge copied to clipboard

Create Serge::Engine::Roles::ErrorMailer

Open prat0088 opened this issue 7 years ago • 1 comments

Created an issue to track the discussion of a change I plan to work on.

I'm writing a new parser plugin. I see 50-100 lines of email notification code duplicated across most plugins. I'd like to factor that out into a reusable utility.

I plan to use Role::Tiny. It has been around for years, has few dependencies, and was recently updated. I initially investigated a solution that didn't require additional modules, but there was no clean and easy way to execute code after init and other parent methods. I also didn't want to introduce another base class, PluginErrorReporter.

I will also create a more generic Mailer role to be used by ErrorMailer and Completeness.

I'll plan on creating a PR for the above enhancements plus Serge::Engine::Plugin::parse_csv.

Feedback is appreciated.

prat0088 avatar Dec 27 '16 23:12 prat0088

Yes, emailing code needs to be separated — thanks for looking into this. I don't think we need to start with Role::Tiny, since this task can be done by the means of interfaces — something Serge is already using — see https://github.com/evernote/serge/tree/master/lib/Serge/Interface. This is basically a way to add common functionality to different plugins without adding new concepts or dependencies. So you can create a new interface that will implement emailing functionality and make plugins reuse it.

iafan avatar Dec 28 '16 08:12 iafan