Jido.Messaging.Directory behaviour (Jido Messaging v1.0.0)

Copy Markdown View Source

Unified directory lookup and search APIs.

Directory adapters expose consistent behavior for participant and room resolution. Lookup returns a single deterministic match and reports {:ambiguous, matches} when a query maps to multiple entities.

Summary

Types

Lookup contract for directory adapters.

Directory query map consumed by adapters.

Search contract for directory adapters.

Supported directory entity targets.

Functions

Lookup a single directory entity for an instance module.

Search directory entities for an instance module.

Types

lookup_result()

@type lookup_result() ::
  {:ok, map()} | {:error, :not_found | {:ambiguous, [map()]} | term()}

Lookup contract for directory adapters.

query()

@type query() :: map()

Directory query map consumed by adapters.

search_result()

@type search_result() :: {:ok, [map()]} | {:error, term()}

Search contract for directory adapters.

target()

@type target() :: :participant | :room

Supported directory entity targets.

Callbacks

lookup(adapter_state, target, query)

@callback lookup(adapter_state :: term(), target(), query()) :: lookup_result()

search(adapter_state, target, query)

@callback search(adapter_state :: term(), target(), query()) :: search_result()

Functions

lookup(instance_module, target, query, opts \\ [])

@spec lookup(module(), target(), query(), keyword()) :: lookup_result()

Lookup a single directory entity for an instance module.

search(instance_module, target, query, opts \\ [])

@spec search(module(), target(), query(), keyword()) :: search_result()

Search directory entities for an instance module.