PacketFlow.Component (packetflow v0.1.0)
Component lifecycle management for PacketFlow
This module provides:
- Component initialization
- Component state management
- Component dependency injection
- Component cleanup
- Component health monitoring
Summary
Functions
Add component dependency
Check component health
Returns a specification to start this module under a supervisor.
Get component health
Get component information
Callback implementation for GenServer.init/1
.
List all components
Register a component
Remove component dependency
Unregister a component
Unwatch component lifecycle events
Update component configuration
Update component state
Watch component lifecycle events
Types
@type component_config() :: map()
@type component_id() :: atom()
@type component_info() :: %{ id: component_id(), module: module(), state: component_state(), config: component_config(), dependencies: [component_id()], health: :healthy | :unhealthy | :degraded, last_heartbeat: integer() }
@type component_state() :: map()
Functions
@spec add_component_dependency(component_id(), component_id()) :: :ok | {:error, String.t()}
Add component dependency
@spec check_component_health(component_id()) :: :ok | {:error, String.t()}
Check component health
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec get_component_health(component_id()) :: :healthy | :unhealthy | :degraded | nil
Get component health
@spec get_component_info(component_id()) :: component_info() | nil
Get component information
Callback implementation for GenServer.init/1
.
@spec list_components() :: [component_id()]
List all components
@spec register_component(component_id(), module(), component_config()) :: {:ok, component_info()} | {:error, String.t()}
Register a component
@spec remove_component_dependency(component_id(), component_id()) :: :ok | {:error, String.t()}
Remove component dependency
@spec unregister_component(component_id()) :: :ok | {:error, String.t()}
Unregister a component
@spec unwatch_component(component_id(), pid()) :: :ok
Unwatch component lifecycle events
@spec update_component_config(component_id(), component_config()) :: :ok | {:error, String.t()}
Update component configuration
@spec update_component_state(component_id(), component_state()) :: :ok | {:error, String.t()}
Update component state
@spec watch_component(component_id(), pid()) :: :ok
Watch component lifecycle events