kraken v0.1.1 Kraken.Client
Main entry point for Kraken requests.
All requests are splitted to partions based on their cost.
Link to this section Summary
Functions
Adds an event to the queue
Gives events for the next stage to process when requested
Issues an HTTP request with the given method to the given url.
This function is usually used indirectly by get/3
, post/4
, put/4
, etc
Args:
method
- HTTP method as an atom (:get
,:head
,:post
,:put
,:delete
, etc.)url
- target url as a binary string or char listbody
- request body. See more belowheaders
- HTTP headers as an orddict (e.g.,[{"Accept", "application/json"}]
)options
- Keyword list of options Body:- binary, char list or an iolist
{:form, [{K, V}, ...]}
- send a form url encoded{:file, "/path/to/file"}
- send a file{:stream, enumerable}
- lazily send a stream of binaries/charlists Options::result_timeout
- receive result timeout, in milliseconds. Default is 2 minutes:timeout
- timeout to establish a connection, in milliseconds. Default is 8000:recv_timeout
- timeout used when receiving a connection. Default is 5000:proxy
- a proxy to be used for the request; it can be a regular url or a{Host, Port}
tuple:proxy_auth
- proxy authentication{User, Password}
tuple:ssl
- SSL options supported by thessl
erlang module:follow_redirect
- a boolean that causes redirects to be followed:max_redirect
- an integer denoting the maximum number of redirects to follow:params
- an enumerable consisting of two-item tuples that will be appended to the url as query string parameters Timeouts can be an integer or:infinity
This function returns{:ok, response}
or{:ok, async_response}
if the request is successful,{:error, reason}
otherwise.
Examples
request(:post, “https://my.website.com”, ~s({“foo”: 3}), [{“Accept”, “application/json”}])
Starts a task with request that must be awaited on
Link to this section Types
Link to this section Functions
Adds an event to the queue
Gives events for the next stage to process when requested
request(atom(), binary(), HTTPoison.body(), HTTPoison.headers(), Keyword.t()) :: {:ok, HTTPoison.Response.t()} | {:error, binary()} | no_return()
Issues an HTTP request with the given method to the given url.
This function is usually used indirectly by get/3
, post/4
, put/4
, etc
Args:
method
- HTTP method as an atom (:get
,:head
,:post
,:put
,:delete
, etc.)url
- target url as a binary string or char listbody
- request body. See more belowheaders
- HTTP headers as an orddict (e.g.,[{"Accept", "application/json"}]
)options
- Keyword list of options Body:- binary, char list or an iolist
{:form, [{K, V}, ...]}
- send a form url encoded{:file, "/path/to/file"}
- send a file{:stream, enumerable}
- lazily send a stream of binaries/charlists Options::result_timeout
- receive result timeout, in milliseconds. Default is 2 minutes:timeout
- timeout to establish a connection, in milliseconds. Default is 8000:recv_timeout
- timeout used when receiving a connection. Default is 5000:proxy
- a proxy to be used for the request; it can be a regular url or a{Host, Port}
tuple:proxy_auth
- proxy authentication{User, Password}
tuple:ssl
- SSL options supported by thessl
erlang module:follow_redirect
- a boolean that causes redirects to be followed:max_redirect
- an integer denoting the maximum number of redirects to follow:params
- an enumerable consisting of two-item tuples that will be appended to the url as query string parameters Timeouts can be an integer or:infinity
This function returns{:ok, response}
or{:ok, async_response}
if the request is successful,{:error, reason}
otherwise.
Examples
request(:post, “https://my.website.com”, ~s({“foo”: 3}), [{“Accept”, “application/json”}])
request_async(atom(), binary(), HTTPoison.body(), HTTPoison.headers(), Keyword.t()) :: Task.t()
Starts a task with request that must be awaited on.