View Source PortServer (PortServer v0.1.0)
The main module exposing the public API of PortServer
PortServer is a standard GenServer implementation.
It can be started manually or through a supervision tree.
You can interact with it through call/3
or cast/3
.
Summary
Functions
Makes a synchronous call to the server
and waits for its reply.
Casts a request to the server
without waiting for a response.
Start PortServer by running a command.
Similar to start/2
except it will call GenServer.start_link/3
instead of
GenServer.start/3
Types
Functions
@spec call(GenServer.server(), String.t(), term(), timeout()) :: term()
Makes a synchronous call to the server
and waits for its reply.
Similar to GenServer.call/3
msg
is the handler name to be called.
payload
can be any term the can be jsonized.
reply = PortServer.call(pid, "func", %{
p1=> "hello",
p2=> 100
})
@spec cast(GenServer.server(), String.t(), term()) :: term()
Casts a request to the server
without waiting for a response.
Similar to GenServer.cast/2
msg
is the handler name to be cast.
payload
can be any term the can be jsonized.
PortServer.cast(pid, "event", %{
p1=> "hello",
p2=> 100
})
@spec start(command(), GenServer.options()) :: GenServer.on_start()
Start PortServer by running a command.
The command is consists of three parts: {"command", "arguments", "options"}
#
{:ok, pid} = PortServer.start({"node", ["./index.js"], [dir: "../"]})
Available options:
:dir
- current working directory.:env
- environment variables.:start_timeout
- Port server must start within the specified time. Otherwise, it will be considered as a initialization failure.
@spec start_link(command(), GenServer.options()) :: GenServer.on_start()
Similar to start/2
except it will call GenServer.start_link/3
instead of
GenServer.start/3