Skip to content

Conversation

kbariotis
Copy link
Contributor

This is my attempt to resolve #8 and its still a WIP.

I would love to hear your thoughts on the configuration part cause Im really not sure this is the way to go.

@coveralls
Copy link

coveralls commented Oct 16, 2016

Coverage Status

Coverage increased (+3.6%) to 59.016% when pulling ab20b9a on kbariotis:add-mailing-support into fa05cc3 on gonsfx:master.

Copy link
Owner

@codepunkt codepunkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job. I know its a WIP and hope i can give a little bit of guidance/direction with my comments.

I'm also going to merge #9 by @Draggha tomorrow, so you might have some merging to do based on that later on.

src/index.js Outdated
this._logger = new Logger(this.config.options.logging)
this._logger.init()

if (this.config.options.mailer.enabled) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible that someone has a config like this, in which case the if statement fails.

{ "options": { "mailer": null } }

I suggest also checking the existence/truthiness of this.config.options.mailer.

await this._logger.logComplete(id)
}

async _handleCompleteAlways (id) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the naming of this method. Could not find a better one that i really liked otoh though :)

this._queue.on('job failed attempt', async (id, msg) => await this._logger.logFailedAttempt(id, msg))
this._queue.on('job failed', async (id, msg) => await this._logger.logFailure(id, msg))
this._queue.on('job complete', async (id) => await this._logger.logComplete(id))
this._queue.on('job start', async (id) => await this._handleStart(id))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracting or not extracting all these methods was largely a matter of choice before. Now that there are at least 2 event handlers that do more than simply logging

  • the complete one that always runs to requeue when defined as a cron
  • the failed one sending mail if configured to do so

So i think its a good choice to do this here!

*/
const defaults = {
nodemailerConfig: {
transportOptions: null,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I think there is a default transportOption we could pursue and add to this project so you don't have to have an smtp server at hand and can simply use this feature by enabling the email option and adding email addresses to the jobs configuration: the nodemailer-sendmail-transport package which uses sendmail under the hood.

Also, overriding the to property based on the email address(es) given in the jobs config file is an important one. When doing so and parsing this somewhere in parseJobs, tests for parseJobs should be updated to reflect this change as well.

@Draggha had to do something like this in his PR for incremental backoff - he added an additional utility method to do the configuration parsing for that which is called inside parseJobs and has its own tests. I like that idea/general direction :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I could rebase my PR when #9 is merged.

@kbariotis
Copy link
Contributor Author

@gonsfx Thank you so much. I have updated the PR.

@coveralls
Copy link

coveralls commented Oct 17, 2016

Coverage Status

Coverage increased (+2.9%) to 58.4% when pulling 0d5d9e1 on kbariotis:add-mailing-support into fa05cc3 on gonsfx:master.

@coveralls
Copy link

coveralls commented Oct 17, 2016

Coverage Status

Coverage increased (+2.9%) to 58.4% when pulling d54c389 on kbariotis:add-mailing-support into fa05cc3 on gonsfx:master.

@codepunkt
Copy link
Owner

@kbariotis looking good. please resolve the conflicts and then i'm up for merging it in 👍

Copy link
Owner

@codepunkt codepunkt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a few review comments - but in the grand scheme of things, this looks good. I might change a few minor things afterwards, but you did a really good job here :)

}
}
```

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice documentation

src/index.js Outdated
this._logger = new Logger(this.config.options.logging)
this._logger.init()

if ('enabled' in this.config.options.mailer &&
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can still crash when someone defines { mailer: null }.
I suggest simply testing for truthiness:

if (this.config.options.mailer && this.config.options.mailer.enabled) {
 // init mailer
}

@coveralls
Copy link

coveralls commented Oct 19, 2016

Coverage Status

Coverage increased (+2.5%) to 63.265% when pulling fabfc9b on kbariotis:add-mailing-support into a109caf on gonsfx:master.

@kbariotis
Copy link
Contributor Author

Comments and merge conflicts resolved. Thank you @gonsfx

@codepunkt codepunkt merged commit 6927507 into codepunkt:master Oct 20, 2016
@codepunkt
Copy link
Owner

@kbariotis Thank you for helping out! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send an email when a job failed

3 participants