Hex.pm versionHex.pm downloadsBuild Status

MachineGun

HTTP client for Elixir. Based on Gun and Poolboy.

Example

%MachineGun.Response{body: body, status_code: 200} =
  MachineGun.post!(
    "https://httpbin.org/anything",
    "{\"hello\":\"world!\"}",
    [{"content-type", "application/json"}, {"accept", "application/json"}],
    %{pool_timeout: 1000, request_timeout: 5000, pool_group: :default})

Options are included to show defaults and can be omitted. pool_timeout and request_timeout default to values specified in pool group configuration. If not specified in pool group configuration they default to the values in the example.

Configuration

config :machine_gun,
  # Default pool group
  default: %{
    pool_size: 4,         # Poolboy size
    pool_max_overflow: 4, # Poolboy max_overflow
    pool_timeout: 1000,
    request_timeout: 5000,
    conn_opts: %{}        # Gun connection options
  }

Configuration example shows defaults and can be omitted. See Poolboy options documentation for explanation of pool_size and pool_max_overflow. See Gun manual for explanation of conn_opts.

Notes