Snap.Cluster behaviour (Snap v0.5.0) 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.

Link to this section Types

Specs

body() :: String.t() | nil | binary() | map()

The body of the HTTP request

Specs

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

result() :: success() | error()

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.

Link to this callback

delete(path, params, headers, opts)

View Source

Specs

delete(path(), params(), headers(), opts()) :: result()

Sends a DELETE request.

Returns either:

Link to this callback

get(path, params, headers, opts)

View Source

Specs

get(path(), params(), headers(), opts()) :: result()

Sends a GET request.

Returns either:

Specs

init(Keyword.t() | nil) :: {:ok, Keyword.t()}

Sets up the config for the cluster.

Override this to dynamically load a config from somewhere other than your application config.

Link to this callback

post(path, body, params, headers, opts)

View Source

Specs

post(path(), body(), params(), headers(), opts()) :: result()

Sends a POST request.

Returns either:

Link to this callback

put(path, body, params, headers, opts)

View Source

Specs

put(path(), body(), params(), headers(), opts()) :: result()

Sends a PUT request.

Returns either: