Snap.Cluster behaviour (Snap v0.2.4) View Source
Defines a cluster.
A cluster maps to an Elasticsearch endpoint.
When used, the cluster expects :otp_app
as an option. The :otp_app
should point to an OTP application that has the cluster configuration. For
example, this cluster:
defmodule MyApp.Cluster do
use Snap.Cluster, otp_app: :my_app
end
Can be configured with:
config :my_app, MyApp.Cluster,
url: "http://localhost:9200",
username: "username",
password: "password",
pool_size: 10
Link to this section Summary
Types
The body of the HTTP request
An error from an HTTP operation
Any additional HTTP headers sent with the request
Options passed through to the request
The query params, which will be appended to the path
The path of the HTTP endpoint
The result from an HTTP operation
A successful results from an HTTP operation
Callbacks
Returns the config in use by this cluster.
Sends a DELETE request.
Sends a GET request.
Sets up the config for the cluster.
Sends a POST request.
Sends a PUT request.
Link to this section Types
Specs
The body of the HTTP request
Specs
error() :: {:error, Snap.Exception.t() | Mint.Types.error() | Jason.DecodeError.t()}
An error from an HTTP operation
Specs
headers() :: Mint.Types.headers()
Any additional HTTP headers sent with the request
Specs
opts() :: Keyword.t()
Options passed through to the request
Specs
params() :: Keyword.t()
The query params, which will be appended to the path
Specs
path() :: String.t()
The path of the HTTP endpoint
Specs
The result from an HTTP operation
Specs
success() :: {:ok, map()}
A successful results from an HTTP operation
Link to this section Callbacks
Specs
config() :: Keyword.t()
Returns the config in use by this cluster.
Specs
Sends a DELETE request.
Returns either:
{:ok, response}
- where response is a map representing the parsed JSON response.{:error, error}
- where the error can be a struct of either:
Specs
Sends a GET request.
Returns either:
{:ok, response}
- where response is a map representing the parsed JSON response.{:error, error}
- where the error can be a struct of either:
Specs
Sets up the config for the cluster.
Override this to dynamically load a config from somewhere other than your application config.
Specs
Sends a POST request.
Returns either:
{:ok, response}
- where response is a map representing the parsed JSON response.{:error, error}
- where the error can be a struct of either:
Specs
Sends a PUT request.
Returns either:
{:ok, response}
- where response is a map representing the parsed JSON response.{:error, error}
- where the error can be a struct of either: