Regula v0.1.0 Regula View Source
A Regula client.
The functions in this module evaluate params against a ruleset and a (optional) version then returns the result in a specific type. They hit Regula’s HTTP API and perform at most client.max_attempts
if the error is retriable.
Returns {:ok, casted_result, %Regula.EvalResult.t()}
so you can inspect the version of the ruleset that was evaluated or the server error that prevented evaluation.
For example, if an integer (64bits) returning ruleset is called with get_string/4
, it will return an error {:error, term}
.
Link to this section Summary
Functions
Creates a client based on given options. Available options are
Evaluates a given ruleset
, params
and (optional) version
and returns a boolean along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned
Evaluates a given ruleset
, params
and (optional) version
and returns a float along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned
Evaluates a given ruleset
, params
and (optional) version
and returns an integer along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned
Evaluates a given ruleset
, params
and (optional) version
and returns a string along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned
Returns a list of rulesets. See Regula.Client.list/3
for more details
Link to this section Types
Link to this section Functions
Creates a client based on given options. Available options are:
endpoint
: url of a regula servermax_attempts
(defaults to 3): max number of attempts made on retriable errors (like network issues).http_client
(optional): a module implementingRegula.HTTPClient
behaviour. Used for testing purposes related to transport errors.
get_bool(Regula.Client.t(), ruleset(), params(), version()) :: {:ok, boolean(), Regula.EvalResult.t()} | {:error, term()}
Evaluates a given ruleset
, params
and (optional) version
and returns a boolean along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned.
get_float(Regula.Client.t(), ruleset(), params(), version()) :: {:ok, float(), Regula.EvalResult.t()} | {:error, term()}
Evaluates a given ruleset
, params
and (optional) version
and returns a float along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned.
get_int(Regula.Client.t(), ruleset(), params(), version()) :: {:ok, integer(), Regula.EvalResult.t()} | {:error, term()}
Evaluates a given ruleset
, params
and (optional) version
and returns an integer along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned.
get_string(Regula.Client.t(), ruleset(), params(), version()) :: {:ok, String.t(), Regula.EvalResult.t()} | {:error, term()}
Evaluates a given ruleset
, params
and (optional) version
and returns a string along with evaluation result for details.
If a network or server error happen, an {:error, term}
is returned.
list(Regula.Client.t(), String.t(), Keyword.t()) :: {:ok, term()} | {:error, term()}
Returns a list of rulesets. See Regula.Client.list/3
for more details.