TypeDB.Transport (TypeDB v0.1.0)

Copy Markdown View Source

Builds, sends and decodes a single TypeDB HTTP request.

This is the layer between the public API modules and the TypeDB.HTTP adapter. It runs entirely in the caller's process; the only time it talks to the connection process is to obtain or renew an access token.

Reach for TypeDB.Connection.request/4 rather than calling this directly.

Summary

Functions

Invokes an HTTP adapter, containing everything it can do wrong.

Executes a request, renewing the token and retrying as configured.

Functions

contain(adapter, where, fun)

@spec contain(module(), String.t(), (-> term())) ::
  {:ok, TypeDB.HTTP.response()} | {:error, TypeDB.Error.t()}

Invokes an HTTP adapter, containing everything it can do wrong.

An adapter is a plug-in point: TypeDB.HTTP is public and anyone may implement it, and even the shipped ones raise — Finch raises rather than returns when its pool is exhausted. Every call into an adapter goes through here, so that a raise, a throw, an exit or a nonsense return value all become the {:ok, response} | {:error, %TypeDB.Error{}} the rest of the driver documents. where names the call for the error message.

request(conn, method, path, opts)

@spec request(TypeDB.Connection.t(), TypeDB.HTTP.method(), String.t(), keyword()) ::
  {:ok, term()} | {:error, TypeDB.Error.t()}

Executes a request, renewing the token and retrying as configured.