ReqLLM.StreamResponse.MetadataHandle (ReqLLM v1.19.0)

View Source

Asynchronous metadata cache that allows multiple awaiters to share the same result.

The handle starts a background process that runs the supplied fetch fun exactly once. Callers can await the metadata multiple times without causing repeated fetches or task mailbox exhaustion. Call stop/1 when the cached metadata is no longer needed.

Summary

Functions

Returns a specification to start this module under a supervisor.

Stops a metadata handle and any in-progress metadata collection.

Types

t()

@type t() :: pid()

Functions

await(handle, timeout \\ :infinity)

@spec await(t(), timeout()) :: map()

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(fetch_fun)

@spec start_link((-> map())) :: {:ok, t()} | {:error, term()}

stop(handle)

@spec stop(t()) :: :ok

Stops a metadata handle and any in-progress metadata collection.

This operation is idempotent and returns :ok when the handle has already stopped.