PacketFlow.Substrate (packetflow v0.1.0)

Dynamic substrate composition and management for PacketFlow

This module provides:

  • Dynamic substrate loading
  • Substrate composition patterns
  • Substrate dependency resolution
  • Substrate configuration
  • Substrate monitoring

Summary

Functions

Returns a specification to start this module under a supervisor.

Get substrate health status

Get substrate information

Callback implementation for GenServer.init/1.

List all substrates

Load a substrate composition

Register a substrate with dynamic loading capabilities

Unregister a substrate

Unwatch substrate

Update substrate configuration

Watch substrate for changes

Types

substrate_config()

@type substrate_config() :: map()

substrate_id()

@type substrate_id() :: atom()

substrate_info()

@type substrate_info() :: %{
  id: substrate_id(),
  module: module(),
  config: substrate_config(),
  dependencies: [substrate_id()],
  status: :active | :inactive | :error,
  load_factor: float(),
  last_heartbeat: integer()
}

Functions

add_substrate_dependency(id, dependency_id)

@spec add_substrate_dependency(substrate_id(), substrate_id()) ::
  :ok | {:error, String.t()}

Add substrate dependency

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_composition(name, substrate_ids, config \\ %{})

@spec create_composition(String.t(), [substrate_id()], map()) ::
  {:ok, String.t()} | {:error, String.t()}

Create a substrate composition

get_substrate_health(id)

@spec get_substrate_health(substrate_id()) :: map() | {:error, String.t()}

Get substrate health status

get_substrate_info(id)

@spec get_substrate_info(substrate_id()) :: substrate_info() | nil

Get substrate information

init(opts)

Callback implementation for GenServer.init/1.

list_substrates()

@spec list_substrates() :: [substrate_id()]

List all substrates

load_composition(name)

@spec load_composition(String.t()) :: {:ok, module()} | {:error, String.t()}

Load a substrate composition

register_substrate(id, module, config \\ %{})

@spec register_substrate(substrate_id(), module(), substrate_config()) ::
  {:ok, substrate_info()} | {:error, String.t()}

Register a substrate with dynamic loading capabilities

remove_substrate_dependency(id, dependency_id)

@spec remove_substrate_dependency(substrate_id(), substrate_id()) ::
  :ok | {:error, String.t()}

Remove substrate dependency

start_link(opts \\ [])

unregister_substrate(id)

@spec unregister_substrate(substrate_id()) :: :ok | {:error, String.t()}

Unregister a substrate

unwatch_substrate(id, pid)

@spec unwatch_substrate(substrate_id(), pid()) :: :ok | {:error, String.t()}

Unwatch substrate

update_substrate_config(id, config)

@spec update_substrate_config(substrate_id(), substrate_config()) ::
  :ok | {:error, String.t()}

Update substrate configuration

watch_substrate(id, pid)

@spec watch_substrate(substrate_id(), pid()) :: :ok | {:error, String.t()}

Watch substrate for changes