WardrikDaemon. Client
(wardrik_daemon v0.1.0-rc.1)
Copy Markdown
Reaches a daemon over its HTTP API. The wardrik command uses it.
client = %WardrikDaemon.Client{url: "http://127.0.0.1:4747", secret: secret}
{:ok, answer} = WardrikDaemon.Client.run(client, "agents.list", %{})Each WardrikProtocol operation is sent to its route, with secret as the bearer token.
Summary
Functions
Stops reading an opened stream.
Returns the next events on an opened stream. Waits at most timeout. Returns :done once the stream ends.
Opens the operation id's events as server-sent events. Read them with next/2.
Runs the operation id with input. Returns its answer, or nil if it answers nothing.
Types
Functions
@spec close(Req.Response.t()) :: :ok
Stops reading an opened stream.
@spec next(Req.Response.t(), timeout()) :: {:ok, [map()], Req.Response.t()} | :done | :timeout
Returns the next events on an opened stream. Waits at most timeout. Returns :done once the stream ends.
@spec open(t(), String.t(), map()) :: {:ok, Req.Response.t()} | error()
Opens the operation id's events as server-sent events. Read them with next/2.
It returns once the daemon is following them, so nothing written after it returns is missed.
Runs the operation id with input. Returns its answer, or nil if it answers nothing.