PacketFlow.Registry.Discovery (packetflow v0.1.0)

Component discovery and lookup mechanisms

This module provides sophisticated component discovery capabilities including:

  • Component pattern matching
  • Component capability matching
  • Component version matching
  • Component health filtering
  • Component load balancing

Summary

Functions

Returns a specification to start this module under a supervisor.

Find components by capability requirements

Find components by type

Find components matching a pattern

Find healthy components only

Get best component match using load balancing

Get component health with caching

Get component metadata

Callback implementation for GenServer.init/1.

Refresh health cache for all components

Register a component for discovery

Unregister a component from discovery

Update component metadata

Types

component_match()

@type component_match() :: %{
  id: atom(),
  module: module(),
  metadata: map(),
  score: float()
}

discovery_pattern()

@type discovery_pattern() :: %{
  name: String.t() | :any,
  type: atom() | :any,
  capabilities: [term()] | :any,
  version: String.t() | :any,
  health: :healthy | :unhealthy | :degraded | :any,
  tags: [String.t()] | :any
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

find_by_capabilities(required_capabilities)

@spec find_by_capabilities([term()]) :: [component_match()]

Find components by capability requirements

find_by_type(component_type)

@spec find_by_type(atom()) :: [component_match()]

Find components by type

find_components(pattern)

@spec find_components(discovery_pattern()) :: [component_match()]

Find components matching a pattern

find_healthy_components(pattern \\ %{})

@spec find_healthy_components(discovery_pattern()) :: [component_match()]

Find healthy components only

get_best_match(pattern, strategy \\ :round_robin)

@spec get_best_match(discovery_pattern(), atom()) :: component_match() | nil

Get best component match using load balancing

get_component_health(id)

@spec get_component_health(atom()) :: :healthy | :unhealthy | :degraded | :unknown

Get component health with caching

get_component_metadata(id)

@spec get_component_metadata(atom()) :: map() | nil

Get component metadata

init(opts)

Callback implementation for GenServer.init/1.

refresh_health_cache()

@spec refresh_health_cache() :: :ok

Refresh health cache for all components

register_component(id, module, metadata \\ %{})

@spec register_component(atom(), module(), map()) :: :ok | {:error, term()}

Register a component for discovery

start_link(opts \\ [])

unregister_component(id)

@spec unregister_component(atom()) :: :ok

Unregister a component from discovery

update_component_metadata(id, metadata)

@spec update_component_metadata(atom(), map()) :: :ok | {:error, term()}

Update component metadata