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

[FEATURE] - Support saving serialized scheduler and reinstating from serialized scheduler #140

Closed
JohnRoesler opened this issue Mar 16, 2021 · 6 comments
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed

Comments

@JohnRoesler
Copy link
Contributor

Is your feature request related to a problem? Please describe

Source: #139

As a user of gocron, I would like to be able to save a scheduler when restarting my application.

Describe the solution you'd like

Expose methods to serialize and de-serialize the scheduler

Describe alternatives you've considered

  • allowing jobs to be saved and re-added, this would be a lot clunkier
  • making scheduler fields exported - this would expose unnecessary details to the end user

Additional context

Example serialization: https://stackoverflow.com/questions/28020070/golang-serialize-and-deserialize-back

// Export serializes the scheduler and returns a base64 encoded string
func (s *Scheduler) Export() string {}

// Import deserializes the scheduler and returns it
func ImportScheduler(in string) *Scheduler {}

I am thinking we'll want to create another struct with export fields that is used for serializing and de-serializing the main scheduler struct which contains unexported fields (which cannot be serialized using gob).

@JohnRoesler JohnRoesler added the enhancement New feature or request label Mar 16, 2021
@JohnRoesler JohnRoesler added this to Requests in v1.2 release via automation Mar 16, 2021
@arjunmahishi arjunmahishi self-assigned this Apr 11, 2021
@arjunmahishi arjunmahishi removed their assignment Aug 28, 2021
@arjunmahishi
Copy link
Member

I was working on this a couple of months back. Got really busy. completely lost context now. That's why I unassigned myself. Will try to take a fresh stab at it if I get time.

But feel free to pick it up

@scottadamsmith
Copy link

Trying to accomplish this in our project as well. Do you think the only fields that need to be serialized on the scheduler are jobs, location, and tagsUnique?

@JohnRoesler
Copy link
Contributor Author

I’d also include the tags map, and the time timewrapper. Are you looking at implementing here? Another option besides creating a struct with exported fields is to implement the serialize and deserialize methods on our structure, which I think is a more ideal route. I’d be happy to discuss / hack at this with you if you’re interested!

@JohnRoesler JohnRoesler added the help wanted Extra attention is needed label Sep 13, 2021
@JohnRoesler
Copy link
Contributor Author

@scottadamsmith
Copy link

For my current situation, being able to wait for running jobs to complete was enough to get me around this requirement. Our jobs are currently at specific times and are also non-critical in the way that if one run was skipped, no big deal. I do think this would be a good feature though. If I can find some time, maybe I'll take a run at it just for the experience and to lend a hand. I'm not 100% when I'll find the time though. I realized after I created this issue that do to everything being non-exported, it would be difficult to do something like this outside of the library itself.

@JohnRoesler
Copy link
Contributor Author

I don’t see this being implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest help wanted Extra attention is needed
Projects
No open projects
v1.2 release
  
Requests
Development

No branches or pull requests

3 participants