View Source Snap.Cluster behaviour (Snap v0.9.0)
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",
index_namespace: "app-dev"
For details about how index namespacing works, see Snap.Cluster.Namespace
.
Summary
Types
The body of the HTTP request
Options available for configuring the Cluster
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.
Types
The body of the HTTP request
@type config_opts() :: [ url: String.t(), username: String.t(), password: String.t(), auth: Snap.Auth.t(), index_namespace: String.t() | nil, telemetry_prefix: [atom()], http_client_adapter: Snap.HTTPClient.t() | {Snap.HTTPClient.t(), adapter_config :: Keyword.t()} ]
Options available for configuring the Cluster
@type error() :: {:error, Snap.ResponseError.t() | Snap.HTTPClient.Error.t() | Jason.DecodeError.t()}
An error from an HTTP operation
@type headers() :: Snap.HTTPClient.headers()
Any additional HTTP headers sent with the request
@type opts() :: Keyword.t()
Options passed through to the request
@type params() :: Keyword.t()
The query params, which will be appended to the path
@type path() :: String.t()
The path of the HTTP endpoint
The result from an HTTP operation
@type success() :: {:ok, map()}
A successful results from an HTTP operation
Callbacks
@callback config() :: Keyword.t()
Returns the config in use by this cluster.
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:
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:
Sets up the config for the cluster.
Override this to dynamically load a config from somewhere other than your application config.
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:
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: