cets_long (cets v0.3.1)
View SourceHelper to log long running operations.
Summary
Types
Extra logging information.
User provided function to execute.
The generic result of execution.
Functions
Runs Fun for its side effects, ignoring any error it raises.
Spawns a new process to do some memory-intensive task.
Runs function Fun.
Types
-type log_info() :: map().
Extra logging information.
-type task_fun() :: fun(() -> task_result()).
User provided function to execute.
-type task_result() :: term().
The generic result of execution.
Functions
-spec run_ignore(task_fun()) -> ok.
Runs Fun for its side effects, ignoring any error it raises.
Used for best-effort calls where a failure is acceptable and either logged elsewhere or intentionally ignored.
-spec run_spawn(log_info(), task_fun()) -> task_result().
Spawns a new process to do some memory-intensive task.
This allows to reduce GC on the parent process. Waits for function to finish. Handles errors. Returns result from the function or crashes (i.e. forwards an error).
-spec run_tracked(log_info(), task_fun()) -> task_result().
Runs function Fun.
Logs errors. Logs if function execution takes too long. Does not catches the errors - the caller would have to catch if they want to prevent an error.