View Source cets_long (cets v0.2.0)

Helper to log long running operations.

Link to this section Summary

Types

Extra logging information.
User provided function to execute.
The generic result of execution.

Functions

Spawns a new process to do some memory-intensive task.

Runs function Fun.

Link to this section 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.

Link to this section 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.