Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause and Resume implementation wrapper using already exisiting functions #894

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mur2zab
Copy link

@mur2zab mur2zab commented Dec 15, 2019

Couldn't find pause and resume functionality in the existing library. Tried to help using the existing functions. Comments are appreciated. First contribution to Open Source.

@AhmadIbrahiim
Copy link

It seems to be perfect if we can add pause and resume to AGENDA!

@simison
Copy link
Member

simison commented Feb 13, 2020

pause('1 day') could be an interesting feature as well (using human-interval. No need in this PR, just noting for future.

@simison
Copy link
Member

simison commented Feb 13, 2020

Should pause the job test seems to be failing at the moment. @mur2zab could you have a look? Thanks!

Could you also add this to documentation (in README.md)

'use strict';
/**
* Pause a job into the MongoDB
* @name Job#
Copy link
Member

Choose a reason for hiding this comment

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

Could you change this to @name @name Job#pause?


/**
* Resumes a job into the MongoDB
* @name Job#
Copy link
Member

Choose a reason for hiding this comment

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

Could you change this to @name @name Job#resume?

* @param when time for the new nextRunAt field
* @returns {Promise} instance of Job that is resumed
*/
module.exports = function(when) {
Copy link
Member

@simison simison Feb 13, 2020

Choose a reason for hiding this comment

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

How would we resume jobs with an interval set? Should we use computeFromInterval?

const computeFromInterval = () => {

@simison
Copy link
Member

simison commented Feb 13, 2020

I'd like to see tests that cover different types of jobs: requrring ones, one-off ones etc. What do you think?

@mur2zab
Copy link
Author

mur2zab commented Feb 14, 2020

Should pause the job test seems to be failing at the moment. @mur2zab could you have a look? Thanks!

Could you also add this to documentation (in README.md)

Sure will look into the comments. Thanks for reviewing @simison

@pdfowler
Copy link
Contributor

pdfowler commented Aug 6, 2021

Proposing we close this as pause/resume implementation is near identical to the existing enable/disable functionality.

From PR in the pause.js file

// Pause
module.exports = function() {
   this.attrs.disabled = true;
   return this.save();
 };

From existing disable file

// Disable
export const disable = function (this: Job): Job {
  this.attrs.disabled = true;
  return this;
};

From a DX perspective, I often got tripped up with which job methods called save internally and which were chainable. I have a strong preference for chainable job methods, and leaving it to the user to call save explicitly.

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

Successfully merging this pull request may close these issues.

None yet

5 participants