[go: up one dir, main page]

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

Is there a way to update a job's original payload? #1566

Open
DevanshB10 opened this issue Jan 20, 2024 · 0 comments
Open

Is there a way to update a job's original payload? #1566

DevanshB10 opened this issue Jan 20, 2024 · 0 comments

Comments

@DevanshB10
Copy link

I am using agenda job, to trigger a request with some payload as follows:

exports.addJob = catchAsync(async(req, res, next) => {
    var requestBody = req.body;
    var user = requestBody.user;
    var scheduledTime = new Date(requestBody.scheduledTime).toUTCString();
    var content = requestBody.content;
    var hash = getEncryptedHash(user, scheduledTime);
    agenda.define(hash, async (job) => {
        try {
            var postData = {
                content: content,
                currentUser: user
            }
            var postUrl = `${process.env.DOMAIN}/api/v1/min-mum` + '/create-post';
            var payload = {
                url: postUrl,
                method: 'POST',
                data: postData,
                headers: {
                    'Content-Type': 'application/json',
                }
            };

            await axios(payload);
            
        } catch(err) {
            console.log(err);
        }
    });
    await startAgenda(hash, scheduledTime);
})

As you can see, I am saving the content and the scheduled time as submitted by the user,
Now the user can update the schedule as well, how do I update the existing job in this case? Is there a way to do this, or do I need to cancel this job and add another job?

@loris @mwbrooks @dawnerd @joeframbach @dandv

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

No branches or pull requests

1 participant