ExMCP.Client.EraCache (ex_mcp v1.0.0-rc.8)

Copy Markdown View Source

Stores protocol-era observations independently of an individual client.

Modern observations do not expire and cannot be replaced by an automatic legacy fallback. Legacy observations have a bounded lifetime so an upgraded server will eventually be probed again. Values used to identify HTTP auth configuration are hashed before they are stored in ETS.

The cache is intentionally process-local. Operators can clear all observations with clear/0, or clear one connection identity by starting a client with reset_era_cache: true.

Summary

Functions

Returns a specification to start this module under a supervisor.

Clears all cached protocol-era observations.

Returns the stable cache identity for a connected transport.

Looks up a non-expired era observation.

Records a successful protocol-era observation.

Types

era()

@type era() :: :legacy | :modern

identity()

@type identity() :: :none | {:configured | :http | :process, binary()}

observation()

@type observation() :: %{
  era: era(),
  protocol_version: String.t(),
  observed_at: integer(),
  expires_at: integer() | :infinity
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear()

@spec clear() :: :ok

Clears all cached protocol-era observations.

identity(transport_mod, transport_state, opts)

@spec identity(module(), term(), keyword()) :: identity()

Returns the stable cache identity for a connected transport.

lookup(identity)

@spec lookup(identity()) :: {:ok, observation()} | :miss

Looks up a non-expired era observation.

observe(identity, era, version, opts \\ [])

@spec observe(identity(), era(), String.t(), keyword()) :: :ok

Records a successful protocol-era observation.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()