ExMCP.Transport.Beam.ServiceRegistry (ex_mcp v0.9.2)
View SourceDistributed service registry for BEAM transport clustering.
Manages registration, discovery, and lifecycle of MCP services across the cluster. Supports multiple discovery strategies and provides efficient lookup and filtering capabilities.
Features
- Multiple Strategies: Local registry, distributed registry, DNS, Consul
- Efficient Lookups: Fast service discovery with flexible filtering
- Circuit Breakers: Track and manage service failures
- Health Tracking: Monitor service health and availability
- Atomic Operations: Consistent state management across nodes
Discovery Strategies
:local_registry- ETS-based local registry (single node):distributed_registry- Distributed ETS with automatic synchronization:dns- DNS-based service discovery:consul- Consul service registry integration
Summary
Functions
Returns a specification to start this module under a supervisor.
Discovers services matching the given filters.
Gets a specific service by ID.
Gets registry statistics.
Records a failure for a service's circuit breaker.
Records a success for a service's circuit breaker.
Registers a service in the registry.
Removes all services from a specific node.
Starts the service registry with the given strategy.
Stops the service registry.
Unregisters a service from the registry.
Updates an existing service registration.
Types
@type service_entry() :: %{ id: String.t(), name: String.t(), version: String.t() | nil, capabilities: [String.t()] | nil, node: atom(), pid: pid(), metadata: map(), health_check: map() | nil, circuit_breaker: ExMCP.Transport.Beam.CircuitBreaker.t() | nil, registered_at: integer(), last_seen: integer() }
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec discover(GenServer.server(), map()) :: {:ok, [service_entry()]} | {:error, term()}
Discovers services matching the given filters.
@spec get(GenServer.server(), String.t()) :: {:ok, service_entry()} | {:error, :not_found}
Gets a specific service by ID.
@spec get_stats(GenServer.server()) :: map()
Gets registry statistics.
@spec record_failure(GenServer.server(), String.t()) :: :ok
Records a failure for a service's circuit breaker.
@spec record_success(GenServer.server(), String.t()) :: :ok
Records a success for a service's circuit breaker.
@spec register(GenServer.server(), map()) :: {:ok, String.t()} | {:error, term()}
Registers a service in the registry.
@spec remove_node_services(GenServer.server(), atom()) :: :ok
Removes all services from a specific node.
@spec start_link(map()) :: GenServer.on_start()
Starts the service registry with the given strategy.
@spec stop(GenServer.server()) :: :ok
Stops the service registry.
@spec unregister(GenServer.server(), String.t()) :: :ok
Unregisters a service from the registry.
@spec update(GenServer.server(), String.t(), map()) :: :ok | {:error, term()}
Updates an existing service registration.