View Single Post
07/01/18, 01:55 AM   #15
SDPhantom
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 47
Originally Posted by votan View Post
There are repeatable actions and non-repeatable events.
repeatable action: Checkbox in the settings: Worse case: User has to do it again. => Can be handled like now.
non-repeatable event: Completing a quest: Worse case: Gone forever. => Should be saved soon.
I still don't see how this changes anything. You either need to save now and call the save function, and if it has to, it waits for the cooldown to finish. There is no way around this as per the design of it. If you call for it to save something not so important (as if marking the save dirty), it does the exact same thing. Which of these two processes do you see as different? A suggestion I would make, if this is the direction we're going, is to have the autosave and manual saves share the same cooldown. Something like 5 minutes seems reasonable to me.



An alternative I would suggest is to add a directive in the manifest that would both have an addon opt-in for autosave and configure how often the author wants it to occur. Something like ## AutoSaveInterval: 5 would set the interval for every 5 minutes. This has to be an integer greater than zero or the directive will be ignored.

In addition, a manual save function will be made available to all addons, regardless of this setting. For the sake of this example, the cooldown for an addon is 1 minute regardless of if processed by autosave or manually done so. A scheduler system should be made to handle the order in which addons save their data. This will act as a queue that iterates through one step every 5 seconds. When processed, addons configured for autosave will be rescheduled according to the interval set in their manifest. Manually calling the save function will modify the schedule to run at the the current timestamp, or 1 minute after the timestamp of the last save, whichever is greater.

To clarify, if an addon that's registered for autosave calls the manual function, it will still reschedule itself the same as if it was triggered by autosave. This supports more urgent saving and preserves the autosave feature at the same time. Duplicate entries for a single addon is not allowed. If there an entry already exists, it should be modified appropriately if the requested timestamp is earlier and the queue re-sorted. This design also allows the queue to fall behind if the step doesn't cycle through fast enough if there are too many addons using it.
  Reply With Quote