View Source Consul.Connection (consulex v0.2.1)
Handle Tesla connections for Consul.
Link to this section Summary
Functions
Builds a base URL based on a given server spec.
Converts a Consul.Request struct into a keyword list to send via Tesla.
Execute a request on this connection
Builds a Tesla client.
Link to this section Types
Specs
t() :: Tesla.Env.client()
Link to this section Functions
Builds a base URL based on a given server spec.
Specs
build_request(Consul.Request.t()) :: keyword()
Converts a Consul.Request struct into a keyword list to send via Tesla.
Specs
execute(Tesla.Client.t(), Consul.Request.t()) :: {:ok, Tesla.Env.t()}
Execute a request on this connection
returns
Returns
{:ok, Tesla.Env.t}- If the call was successful{:error, reason}- If the call failed
Builds a Tesla client.
options
Options
adapter- specify custom Tesla adapter, if not set will use Tesla's default oneretry- options forTesla.Middleware.Retrymiddlewaretimeout- when given, will includeTesla.Middleware.Timeoutmiddleware configured with given valuetoken- when given, will includex-consul-tokenheader with given value in the requestswait- when given, will includeTesla.Middleware.ConsulWatchmiddleware configured with given value in milliseconds
When using wait option, make sure its value is larger than the timeout
used by the underlying adapter (specified in options or default one).
Otherwise, the request may be timing out before wait period passes.
Note that using timeout option is not always sufficient to achieve this
as some adapters (e.g. Tesla.Adapter.Finch) are not compatible with
Tesla.Middleware.Timeout middleware that is used when timeout option
is specified.