Spear.request

You're seeing just the function request, go back to Spear module for more information.
Link to this function

request(conn, api, rpc, messages, opts \\ [])

View Source (since 0.3.0)

Specs

request(
  connection :: Spear.Connection.t(),
  api :: module(),
  rpc :: atom(),
  messages :: Enumerable.t(),
  opts :: Keyword.t()
) :: {:ok, tuple() | Enumerable.t()} | {:error, any()}

Performs a generic request synchronously

This is appropriate for many operations across the Users, Streams, and Operations APIs but not suitable for Spear.subscribe/4 or the Persistent Subscriptions API.

message must be an enumeration of records as created by the Record Interfaces. Lazy stream enumerations are allowed and are not run until each element is serialized over the wire.

This function is mostly used under-the-hood to implement functions in Spear such as Spear.create_user/5, but may be used generically.

Options

  • :timeout - (default: 5_000ms - 5s) the GenServer timeout: the maximum time allowed to wait for this request to complete.
  • :credentials - (default: nil) the username and password to use to make the request. Overrides the connection-level credentials if provided. Connection-level credentials are used as the default if not provided.

Examples

iex> alias Spear.Records.Users
iex> require Users
iex> message = Users.enable_req(options: Users.enable_req_options(login_name: "my_user"))
iex> Spear.request(conn, Users, :Enable, [message], credentials: {"admin", "changeit"})
{:ok, Users.enable_resp()}