View Source cets_long (cets v0.3.0)
Helper to log long running operations.
Summary
Types
Extra logging information.
User provided function to execute.
The generic result of execution.
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_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.