The transport behind every generated operation.
Generated operation functions end in a call to request/1 with a description
of the call. This module turns that description into a Req request, sends
it, and normalises the result to {:ok, term} or {:error, Gleanex.Error.t()}.
Per call options
Every generated operation takes a trailing opts keyword list. Alongside the
operation's own query parameters it understands:
:config- theGleanex.Configto use. Falls back toGleanex.Config.default/0, which reads the application and system environment.:receive_timeout- override the config's timeout for this call.:retry- override the config'sGleanex.Retrypolicy for this call.:req_options- extraReqoptions, merged over the config's.:client- swap this module out entirely, handled by the generated code.
Telemetry
Each request emits a span under [:gleanex, :request]:
[:gleanex, :request, :start]with%{system_time: integer}[:gleanex, :request, :stop]with%{duration: integer}[:gleanex, :request, :exception]with%{duration: integer}
Metadata carries :api, :operation, :method and :url, and the stop event
adds :status or :error.
Summary
Functions
@spec api_for({module(), atom()} | module() | nil) :: Gleanex.Config.api()
Which of the four APIs an operation module belongs to.
Derived from the module name, so Gleanex.Indexing.Documents resolves to
:indexing. Unrecognised modules fall back to :client.
@spec build_request(Gleanex.Config.t(), Gleanex.Config.api(), map()) :: Req.Request.t()
Build the Req request for an operation without sending it.
Exposed for Gleanex.Streaming, which needs the same URL, auth and retry
handling but has to consume the response body as it arrives rather than all at
once. Options under the operation's :opts are applied last, so a caller can
add into: :self through req_options.
@spec request(map()) :: {:ok, term()} | {:error, Gleanex.Error.t()}
Run a generated operation description.