Exos.Proc (exos v2.1.0)

View Source

Summary

Functions

Returns a specification to start this module under a supervisor.

Callback implementation for GenServer.init/1.

Launch a GenServer which starts a port and proxify cast and call to it using a port protocol with packet: 4, (32bits-length+data) messages are transmitted throught stdin/out. Input terms are encoded using binary_to_term and received terms are decoded using term_to_binary.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

init(arg)

Callback implementation for GenServer.init/1.

start_link(cmd, init, opts \\ [])

start_link(cmd, init, port_opts, gen_server_opts)

This function is deprecated. Use Elixir.Exos.Proc.start_link/3 instead.

start_link(cmd, init, port_opts, gen_server_opts, event_fun)

This function is deprecated. Use Elixir.Exos.Proc.start_link/3 instead.

Launch a GenServer which starts a port and proxify cast and call to it using a port protocol with packet: 4, (32bits-length+data) messages are transmitted throught stdin/out. Input terms are encoded using binary_to_term and received terms are decoded using term_to_binary.

  • cmd is the shell command to launch the port
  • when the port starts, it automatically receives as first message the init term if init !== :no_init
  • port_opts are options for Port.open (for instance [cd: "/path/"])
  • gen_server_opts are options for GenServer.start_link (for instance [name: :servername])
  • messages received from the port outside of a GenServer.call context trigger a event_fun.(event) call if event_fun is not nil (default)
  • etf_opts are options for :erlang.term_to_binary and :erlang.binary_to_term
  • to allow easy supervision, if the port die with a return code == 0, then the GenServer die with the reason :normal, else with the reason :port_terminated