Evaluate many states against one question set, concurrently.
The question set is validated and encoded once; each state then gets its own
TypeSafe.evaluate/4 call in a task. Results come back in input order by
default, one {:ok, result} or {:error, error} per state, so a single
failure never hides the other results.
Concurrency
max_concurrency defaults to 8. That number is a guess: TypeSafe has not
published rate limits or an SLA at the time of writing. Raise it if your
account allows, and watch for :rate_limited errors (the retry policy
absorbs short bursts of 429s before they surface).
Each task is bounded by timeout, which must cover the whole retry budget of
a single call. The default is the client's retry budget plus one attempt's
timeout, or 60 seconds when the budget is disabled.
:timeout here is the task timeout, not the single-attempt HTTP timeout.
Use :attempt_timeout for the latter; it defaults to the client's timeout.
When retries run out
A state whose retries are exhausted is not special. It comes back as an
ordinary {:error, %TypeSafe.Error{type: :rate_limited, retry_after_ms: ms}}
in that state's position, next to the states that succeeded, and the batch
keeps going. With on_error: :raise that same error is raised instead, once
every task has been collected.
With ordered: false the outcomes arrive as they finish rather than in
input order, so under on_error: :raise the error that raises is the first
one to finish, which is not necessarily the earliest state in the input.
If you need the failure to be reproducible, keep ordered: true.
retry_after_ms is carried on the error so the caller can back off before
the next batch. The per-call retry policy has already given up by the time
you see it, so the useful move is to sleep for the longest retry_after_ms
in the batch, then resend just the failed states.
Summary
Functions
Evaluates each state in states against questions.
The options evaluate_many/4 handles itself.
Types
@type outcome() :: {:ok, TypeSafe.Result.t()} | {:error, TypeSafe.Error.t()}
Functions
@spec evaluate_many( TypeSafe.Client.t(), Enumerable.t(), TypeSafe.Question.input(), keyword() ) :: [outcome()] | {:error, TypeSafe.Error.t()}
Evaluates each state in states against questions.
Returns a list of outcomes (in input order unless ordered: false), or
{:error, error} when the question set itself is invalid.
Options
:max_concurrency(pos_integer/0) - Maximum number of in-flight requests. A guess; see the module docs. The default value is8.:timeout- Per-state task timeout in milliseconds, covering every retry of that state. Defaults to the retry budget plus one attempt timeout, or 60 000 when the budget is disabled.:attempt_timeout(pos_integer/0) - Timeout in milliseconds for one HTTP attempt; defaults to the client's.:ordered(boolean/0) - Return results in input order.falseyields them as they finish. The default value istrue.:on_error-:collectreturns error tuples in place;:raiseraises the first error. The default value is:collect.
Every other option (:model, :retry, :req_options, :telemetry) is
passed to each call; see TypeSafe.SystemOne.options_schema/0.
@spec options_schema() :: NimbleOptions.t()
The options evaluate_many/4 handles itself.
Every other option is passed through to each individual call; see
TypeSafe.SystemOne.options_schema/0.
:max_concurrency(pos_integer/0) - Maximum number of in-flight requests. A guess; see the module docs. The default value is8.:timeout- Per-state task timeout in milliseconds, covering every retry of that state. Defaults to the retry budget plus one attempt timeout, or 60 000 when the budget is disabled.:attempt_timeout(pos_integer/0) - Timeout in milliseconds for one HTTP attempt; defaults to the client's.:ordered(boolean/0) - Return results in input order.falseyields them as they finish. The default value istrue.:on_error-:collectreturns error tuples in place;:raiseraises the first error. The default value is:collect.