MeshxConsul.Service.Endpoint (MeshxConsul v0.1.0) View Source
Consul agent http API endpoint.
MeshxConsul is using OTP :httpc HTTP client to access Consul agent HTTP API endpoint when managing services and upstreams. Required by :httpc configuration is described in MeshxConsul Configuration options section.
Example
Query Consul KV store:
iex(1)> MeshxConsul.Service.Endpoint.put("/kv/my-key", "my-key_value")
:ok
iex(2)> MeshxConsul.Service.Endpoint.get("/kv/my-key", %{raw: true})
{:ok, 'my-key_value'}
iex(3)> MeshxConsul.Service.Endpoint.delete("/kv/my-key")
:ok
iex(4)> MeshxConsul.Service.Endpoint.get("/kv/my-key")
{:error,
[{{'HTTP/1.1', 404, 'Not Found'}, [...], []},
"Get request uri: [http:///v1/kv/my-key?]"
]}
Link to this section Summary
Functions
Issues DELETE request at path.
Returns GET request response at path API endpoint address.
PUT payload at path API endpoint address.
Returns configuration and member information of the local agent using /agent/self Consul HTTP API endpoint.
Link to this section Functions
Specs
Issues DELETE request at path.
Specs
Returns GET request response at path API endpoint address.
Specs
put(path :: String.t(), payload :: String.t() | map(), query :: map()) :: :ok | {:error, reason :: term()}
PUT payload at path API endpoint address.
Specs
Returns configuration and member information of the local agent using /agent/self Consul HTTP API endpoint.
iex(1)> MeshxConsul.Service.Endpoint.self()
{:ok,
%{
"Config" => %{
"Datacenter" => "my-dc",
"NodeName" => "h11",
...
}
...
}
}