PacketFlow.Substrate.Interface behaviour (packetflow v0.1.0)

Standard interfaces for PacketFlow substrates

This module defines the standard interfaces that all substrates must implement for proper communication, composition, and monitoring.

Summary

Callbacks

Substrate security interface

Substrate transaction interface

Substrate composition interface

Substrate backup interface

Substrate discovery interface

Substrate capability interface

Substrate debugging interface

Substrate dependency interface

Substrate monitoring interface

Substrate data flow interface

Substrate metrics interface

Substrate resource management interface

Substrate state management interface

Substrate time management interface

Substrate versioning interface

Substrate fault tolerance interface

Substrate initialization interface

Substrate integration interface

Substrate migration interface

Substrate optimization interface

Substrate scaling interface

Substrate communication interface

Substrate serialization interface

Substrate lifecycle interface

Substrate event interface

Substrate notification interface

Substrate configuration interface

Substrate validation interface

Functions

Substrate validation helpers

Callbacks

accept_migration(migrating_substrate, state)

@callback accept_migration(migrating_substrate :: module(), state :: map()) ::
  :ok | {:error, reason :: any()}

add_dependency(dependency)

@callback add_dependency(dependency :: module()) :: :ok | {:error, reason :: any()}

authenticate(credentials)

@callback authenticate(credentials :: map()) ::
  {:ok, permissions :: [atom()]} | {:error, reason :: any()}

Substrate security interface

authorize(permission, resource)

@callback authorize(permission :: atom(), resource :: any()) :: boolean()

begin_transaction()

@callback begin_transaction() ::
  {:ok, transaction_id :: atom()} | {:error, reason :: any()}

Substrate transaction interface

clear_failure_history()

@callback clear_failure_history() :: :ok

commit_transaction(transaction_id)

@callback commit_transaction(transaction_id :: atom()) :: :ok | {:error, reason :: any()}

compose_with(other_substrate, config)

@callback compose_with(other_substrate :: module(), config :: map()) ::
  {:ok, composed_module :: module()} | {:error, reason :: any()}

Substrate composition interface

connect_port(port_type, port_id, target)

@callback connect_port(port_type :: :input | :output, port_id :: atom(), target :: any()) ::
  :ok | {:error, reason :: any()}

create_backup()

@callback create_backup() :: {:ok, backup_data :: map()} | {:error, reason :: any()}

Substrate backup interface

deserialize_state(serialized)

@callback deserialize_state(serialized :: binary()) ::
  {:ok, state :: map()} | {:error, reason :: any()}

disconnect_from(integration_id)

@callback disconnect_from(integration_id :: atom()) :: :ok | {:error, reason :: any()}

disconnect_port(port_type, port_id)

@callback disconnect_port(port_type :: :input | :output, port_id :: atom()) ::
  :ok | {:error, reason :: any()}

discover_peers()

@callback discover_peers() :: [map()]

Substrate discovery interface

emit_event(event, data)

@callback emit_event(event :: atom(), data :: any()) :: :ok

get_capabilities()

@callback get_capabilities() :: [atom()]

Substrate capability interface

get_debug_info()

@callback get_debug_info() :: map()

Substrate debugging interface

get_dependencies()

@callback get_dependencies() :: [module()]

Substrate dependency interface

get_failure_history()

@callback get_failure_history() :: [map()]

get_health_status()

@callback get_health_status() :: map()

Substrate monitoring interface

get_input_ports()

@callback get_input_ports() :: [map()]

Substrate data flow interface

get_logs()

@callback get_logs() :: [String.t()]

get_metrics()

@callback get_metrics() :: map()

Substrate metrics interface

get_output_ports()

@callback get_output_ports() :: [map()]

get_performance_stats()

@callback get_performance_stats() :: map()

get_resource_limits()

@callback get_resource_limits() :: map()

get_resource_usage()

@callback get_resource_usage() :: map()

Substrate resource management interface

get_scaling_recommendations()

@callback get_scaling_recommendations() :: [map()]

get_state()

@callback get_state() :: map()

Substrate state management interface

get_time_constraints()

@callback get_time_constraints() :: [map()]

Substrate time management interface

get_version()

@callback get_version() :: String.t()

Substrate versioning interface

handle_failure(failure)

@callback handle_failure(failure :: map()) :: :ok | {:error, reason :: any()}

Substrate fault tolerance interface

has_capability(capability)

@callback has_capability(capability :: atom()) :: boolean()

init_substrate(config)

@callback init_substrate(config :: map()) ::
  {:ok, state :: map()} | {:error, reason :: any()}

Substrate initialization interface

integrate_with(external_system, config)

@callback integrate_with(external_system :: atom(), config :: map()) ::
  {:ok, integration_id :: atom()} | {:error, reason :: any()}

Substrate integration interface

is_compatible_with(other_version)

@callback is_compatible_with(other_version :: String.t()) :: boolean()

is_within_time_constraints()

@callback is_within_time_constraints() :: boolean()

migrate_to(target_node)

@callback migrate_to(target_node :: atom()) :: :ok | {:error, reason :: any()}

Substrate migration interface

optimize()

@callback optimize() :: {:ok, optimizations :: [map()]} | {:error, reason :: any()}

Substrate optimization interface

record_metric(metric, value)

@callback record_metric(metric :: atom(), value :: any()) :: :ok

register_with_registry(registry)

@callback register_with_registry(registry :: atom()) :: :ok | {:error, reason :: any()}

remove_dependency(dependency)

@callback remove_dependency(dependency :: module()) :: :ok | {:error, reason :: any()}

reset_state()

@callback reset_state() :: :ok | {:error, reason :: any()}

restart_substrate()

@callback restart_substrate() :: :ok | {:error, reason :: any()}

restore_from_backup(backup_data)

@callback restore_from_backup(backup_data :: map()) :: :ok | {:error, reason :: any()}

rollback_transaction(transaction_id)

@callback rollback_transaction(transaction_id :: atom()) ::
  :ok | {:error, reason :: any()}

scale_down(factor)

@callback scale_down(factor :: float()) :: :ok | {:error, reason :: any()}

scale_up(factor)

@callback scale_up(factor :: float()) :: :ok | {:error, reason :: any()}

Substrate scaling interface

send_message(message, target)

@callback send_message(message :: any(), target :: any()) ::
  {:ok, response :: any()} | {:error, reason :: any()}

Substrate communication interface

send_notification(notification_type, data)

@callback send_notification(notification_type :: atom(), data :: any()) :: :ok

serialize_state()

@callback serialize_state() :: binary()

Substrate serialization interface

set_debug_level(level)

@callback set_debug_level(level :: atom()) :: :ok

set_resource_limits(limits)

@callback set_resource_limits(limits :: map()) :: :ok | {:error, reason :: any()}

set_state(state)

@callback set_state(state :: map()) :: :ok | {:error, reason :: any()}

set_time_constraints(constraints)

@callback set_time_constraints(constraints :: [map()]) :: :ok | {:error, reason :: any()}

start_substrate()

@callback start_substrate() :: :ok | {:error, reason :: any()}

Substrate lifecycle interface

stop_substrate()

@callback stop_substrate() :: :ok | {:error, reason :: any()}

subscribe_to_events(pid)

@callback subscribe_to_events(pid :: pid()) :: :ok | {:error, reason :: any()}

Substrate event interface

subscribe_to_notifications(pid, notification_types)

@callback subscribe_to_notifications(pid :: pid(), notification_types :: [atom()]) ::
  :ok | {:error, reason :: any()}

Substrate notification interface

unregister_from_registry(registry)

@callback unregister_from_registry(registry :: atom()) :: :ok | {:error, reason :: any()}

unsubscribe_from_events(pid)

@callback unsubscribe_from_events(pid :: pid()) :: :ok | {:error, reason :: any()}

unsubscribe_from_notifications(pid)

@callback unsubscribe_from_notifications(pid :: pid()) :: :ok | {:error, reason :: any()}

update_config(config)

@callback update_config(config :: map()) :: :ok | {:error, reason :: any()}

Substrate configuration interface

update_state(updates)

@callback update_state(updates :: map()) :: :ok | {:error, reason :: any()}

validate_config(config)

@callback validate_config(config :: map()) ::
  {:ok, validated_config :: map()} | {:error, reason :: any()}

Substrate validation interface

validate_message(message)

@callback validate_message(message :: any()) ::
  {:ok, validated_message :: any()} | {:error, reason :: any()}

Functions

__using__(opts)

(macro)

Substrate validation helpers