HTTP+mTLS POST of a SOAP envelope.
A behaviour, so a host can substitute its own transport and so mix test
never opens a socket. SefazNfe.SOAP.HTTPC is the default implementation.
Telemetry timing
The [:sefaz_nfe, :soap] span measures the total duration of the request
only. :httpc exposes no per-phase timing (connect, transmit, response), and
measuring them separately would mean opening the TLS connection outside
:httpc, which changes behaviour; the default transport therefore does not
split them. A custom SefazNfe.SOAP client that can see the phases may emit
finer events of its own.
Summary
Types
@type cert() :: SefazNfe.Certificate.t()
Callbacks
Functions
@spec client() :: module()
The configured client, defaulting to the real mTLS one.
The default is deliberately the working client: a host that installs this
library should be able to call SEFAZ without extra configuration. The test
suite swaps it for SefazNfe.SOAP.NotImplemented in config/test.exs, which
is what keeps mix test off the network.
@spec isolated_call(String.t(), iodata(), cert(), keyword()) :: {:ok, String.t()} | {:error, term()}
Runs call/4 in SefazNfe.TaskSupervisor so an SSL/SOAP abort
does not take down the caller (Jurić: I/O failure domain).
Emits [:sefaz_nfe, :soap, :start | :stop | :exception] (SEFAZ-14). The
:uf, :environment, :model and :contingency options are consumed here
as telemetry metadata, with :service (see SefazNfe.Telemetry); every other option,
:timeout and :connect_timeout included, is forwarded to call/4: they
govern the request, and the task window follows them rather than the other way
round. Metadata never carries the certificate, the password or the XML body —
only the endpoint, the UF, the service and an outcome tag. That tag is deliberately low cardinality: the raw
reason would drag a whole {:soap_crash, stacktrace} into every metrics
label.
Calls are gated by SefazNfe.CircuitBreaker keyed by the endpoint's host
(https://host:port, lower case), the server actually called: a server that
stops answering fails fast instead of costing every caller a full timeout,
without touching other models of the same UF or other UFs on other servers.
The key is also the :host metadata of the span.