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

Add new Run Now button + fix on callback #8

Closed
wants to merge 1 commit into from

Conversation

chaadow
Copy link
Contributor

@chaadow chaadow commented Sep 13, 2024

There are times where we don't want to wait for the event to happen and manually execute/run the event.

This PR introduces:

  • a new Run now button next to the Enable/Disable button

    • After carefully reading clockwork source code, using event.run(Time.now) handles the setting of event.last
    • it also calls set_last_run to update redis as well.
  • Setting Last run in after_run callback

    • I usually have every(1.minutes, 'job_name') { SomeSidekiqJob.perform_async }
    • What can happen here, is that the block can raise an exception. For my case, it can be redis ( the one for Sidekiq not clockwork_web) is down or Out Of Memory for example. But it can also be any ruby error
    • So setting "last_run" on Clockwork_web's redis after being run is a safer and more accurate way to set it than setting it before it's run, which can be misleading

    Here is a screenshot:

image

@ankane
Copy link
Owner

ankane commented Dec 4, 2024

Hi @chaadow, thanks for the PR. However, I'd prefer to keep the functionality minimal and (personally) think it's more useful to see when the job was last started by the scheduler.

@ankane ankane closed this Dec 4, 2024
@chaadow
Copy link
Contributor Author

chaadow commented Dec 6, 2024

@ankane Imagine these 2 use cases :

  • First use case is : you disable the job temporarily ( feature already present in clockwork_web) then you re-enable it, but you want to run the re-enabled job without waiting for say, another 24 hour or so. so the Run now can help in that case.
  • Second use case: The job was called, and it delegated to say ActiveJob/Sidekiq. but the sidekiq job itself failed, and you got a Sentry error. You deploy a fix. You know that the job was not run even though clockwork_web says it did ==> so the Run now in this case can help as well.

From an implementation standpoint, it is pretty simple as well, as it simply calls the stored lambda again.

And on a personal level, I've been using my fork in producition, and the Run now has helped us tremendously. a recent use case, is we were rate-limited by an API. so we had to re-run a job to make sure it was properly handled.

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.

2 participants