PacketFlow.Component.Configuration (packetflow v0.1.0)

Component configuration interfaces for dynamic configuration

This module provides:

  • Dynamic configuration management
  • Configuration validation and schema definitions
  • Runtime configuration updates
  • Configuration templates and profiles
  • Configuration versioning and rollback
  • Environment-specific configurations

Summary

Functions

Apply a configuration template to a component

Returns a specification to start this module under a supervisor.

Export configuration to file

Get all component configurations

Get configuration for a component

Get configuration history for a component

Get configuration schema for a component

Get a specific configuration value

Import configuration from file

Callback implementation for GenServer.init/1.

Register a component configuration with schema

Rollback to a previous configuration version

Unregister a component configuration

Unwatch configuration changes

Update configuration for a component

Update configuration schema for a component

Update a specific configuration value

Validate configuration against schema

Watch configuration changes for a component

Types

component_config()

@type component_config() :: %{
  component_id: atom(),
  config: map(),
  schema: %{required(config_key()) => config_schema()},
  version: String.t(),
  environment: atom(),
  last_updated: integer(),
  metadata: map()
}

config_key()

@type config_key() :: atom() | String.t() | [atom() | String.t()]

config_schema()

@type config_schema() :: %{
  type: :string | :integer | :float | :boolean | :list | :map | :atom,
  required: boolean(),
  default: config_value(),
  validator: function() | nil,
  description: String.t()
}

config_template()

@type config_template() :: %{
  name: String.t(),
  description: String.t(),
  config: map(),
  schema: %{required(config_key()) => config_schema()},
  environments: [atom()]
}

config_value()

@type config_value() :: term()

Functions

apply_config_template(component_id, template_name)

@spec apply_config_template(atom(), String.t()) :: :ok | {:error, term()}

Apply a configuration template to a component

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_config_template(name, description, config, schema, environments \\ [:dev, :test, :prod])

@spec create_config_template(String.t(), String.t(), map(), map(), [atom()]) ::
  :ok | {:error, term()}

Create a configuration template

export_config(component_id, file_path)

@spec export_config(atom(), String.t()) :: :ok | {:error, term()}

Export configuration to file

get_all_configs()

@spec get_all_configs() :: %{required(atom()) => component_config()}

Get all component configurations

get_config(component_id)

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

Get configuration for a component

get_config_history(component_id)

@spec get_config_history(atom()) :: [component_config()] | {:error, term()}

Get configuration history for a component

get_config_schema(component_id)

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

Get configuration schema for a component

get_config_value(component_id, key)

@spec get_config_value(atom(), config_key()) :: config_value() | {:error, term()}

Get a specific configuration value

import_config(component_id, file_path)

@spec import_config(atom(), String.t()) :: :ok | {:error, term()}

Import configuration from file

init(opts)

Callback implementation for GenServer.init/1.

register_component_config(component_id, initial_config, schema)

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

Register a component configuration with schema

rollback_config(component_id, version)

@spec rollback_config(atom(), String.t()) :: :ok | {:error, term()}

Rollback to a previous configuration version

start_link(opts \\ [])

unregister_component_config(component_id)

@spec unregister_component_config(atom()) :: :ok

Unregister a component configuration

unwatch_config(component_id, watcher_pid)

@spec unwatch_config(atom(), pid()) :: :ok

Unwatch configuration changes

update_config(component_id, new_config)

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

Update configuration for a component

update_config_schema(component_id, schema)

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

Update configuration schema for a component

update_config_value(component_id, key, value)

@spec update_config_value(atom(), config_key(), config_value()) ::
  :ok | {:error, term()}

Update a specific configuration value

validate_config(component_id, config)

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

Validate configuration against schema

watch_config(component_id, watcher_pid)

@spec watch_config(atom(), pid()) :: :ok

Watch configuration changes for a component