hecate_plugin_scheduler (hecate_sdk v0.6.2)
View SourceCron-like recurring task scheduler for plugins.
Plugins can schedule periodic tasks that run in their own process. Tasks are lightweight — each is a spawned process with a timer.
Usage: %% Run every 5 minutes hecate_plugin_scheduler:every(5 * 60 * 1000, fun cleanup_expired/0).
%% Run every hour with a name (for cancellation) Ref = hecate_plugin_scheduler:every(3600000, fun sync_remote/0), hecate_plugin_scheduler:cancel(Ref).
Summary
Functions
Cancel a scheduled task.
Schedule a function to run every IntervalMs milliseconds. Returns a reference that can be used to cancel.
Schedule with options. Options: - initial_delay: milliseconds before first run (default: IntervalMs) - name: atom for logging (default: anonymous)
Functions
-spec cancel(reference()) -> ok.
Cancel a scheduled task.
-spec every(IntervalMs :: pos_integer(), Fun :: fun(() -> term())) -> reference().
Schedule a function to run every IntervalMs milliseconds. Returns a reference that can be used to cancel.
-spec every(pos_integer(), fun(() -> term()), map()) -> reference().
Schedule with options. Options: - initial_delay: milliseconds before first run (default: IntervalMs) - name: atom for logging (default: anonymous)