Utility functions for the exometer_proc
probe type.
The exometer_proc
probe type is a vanilla Erlang process. All messages
must be handled explicitly.
The functions in this module can be used by custom types
(see e.g. exometer_spiral
). When the exometer_proc
type is
specified explicitly, the process is started automatically, and the
following messages:
lang="erlang"
{exometer_proc, {update, Value}}
{exometer_proc, sample}
{exometer_proc, reset}
{exometer_proc, {Pid,Ref}, {get_value, Datapoints}} -> {Ref, Reply}
{exometer_proc, {Pid,Ref}, {setopts, Opts}} -> {Ref, Reply}
{exometer_proc, stop}
call/2 | Make a synchronous call to an exometer_proc process. |
cast/2 | Send an asynchronous message to an exometer_proc process. |
format_status/2 | |
handle_system_msg/4 | |
process_options/1 | Apply process_flag-specific options. |
spawn_process/2 | Spawn an exometer_proc process. |
spawn_process/3 | |
stop/0 | Terminate probe process in an orderly way. |
system_code_change/4 | |
system_continue/3 | |
system_terminate/4 |
call(Pid::pid() | atom(), Req::any()) -> any()
Make a synchronous call to an exometer_proc
process.
Note that the receiving process must explicitly handle the message in a
receive
clause and respond properly. The protocol is:
lang="erlang"
call(Pid, Req) ->
MRef = erlang:monitor(process, Pid),
Pid ! {exometer_proc, {self(), MRef}, Req},
receive
{MRef, Reply} -> Reply
after 5000 -> error(timeout)
end.
cast(Pid::pid() | atom(), Msg::any()) -> ok
Send an asynchronous message to an exometer_proc
process.
This function sends a message on the form {exometer_proc, Msg}
to the
given process.
format_status(Opt, StatusData) -> any()
handle_system_msg(Req, From, State, Cont) -> any()
process_options(Opts::[{atom(), any()}]) -> ok
Apply process_flag-specific options.
spawn_process(Name::exometer:name(), F::fun(() -> no_return())) -> pid()
Spawn an exometer_proc
process.
This function sets up appropriate monitoring, and calls the function F
which needs to initialize the probe and enter an event loop.
(Note: exometer_proc
processes are responsible for their own event loop).
spawn_process(Name, F, Opts) -> any()
stop() -> no_return()
Terminate probe process in an orderly way.
This function doesn't return.
system_code_change(IntState, Module, OldVsn, Extra) -> any()
system_continue(Parent, Debug, IntState) -> any()
system_terminate(Reason, Parent, Debug, State) -> any()