RustlerElixirFun.FunExecutionServer (rustler_elixir_fun v0.1.0)

This GenServer listens for native code to send sets of functions + parameters to it.

It will then execute these functions (by calling apply(fun, parameters) on them), and return the results to the native code.

iex> {:ok, pid} = RustlerElixirFun.FunExecutionServer.start_link([])
iex> RustlerElixirFun.Internal.apply_elixir_fun(pid, fn x -> x * 2 end, [10])
{:ok, 20}

It is recommended to use a registered name (and start the process in a supervision tree) to make sure that you won't have to handle checking PIDs for aliveness in native code:

iex> {:ok, _} = RustlerElixirFun.FunExecutionServer.start_link([name: :my_fancy_worker_server])
iex> RustlerElixirFun.Internal.apply_elixir_fun(:my_fancy_worker_server, fn x -> x * 2 end, [42])
{:ok, 84}

If you might call a function many times in short succession, or want to call many different functions, it might make sense to use RustlerElixirFun.Pool instead.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

start_link(gen_server_options)