PacketFlow.Intent.Dynamic (packetflow v0.1.0)
Dynamic intent processing and routing system for PacketFlow
This module provides runtime intent creation, dynamic routing, composition patterns, validation plugins, and transformation plugins.
Summary
Functions
Compose multiple intents using different composition patterns
Create a composite intent from multiple intents
Create an intent dynamically at runtime
Delegate an intent to another processor
Route an intent dynamically based on its type and capabilities
Transform an intent using registered transformation plugins
Validate an intent using registered validation plugins
Functions
Compose multiple intents using different composition patterns
Examples
# Sequential composition
result = PacketFlow.Intent.Dynamic.compose_intents([
intent1,
intent2,
intent3
], :sequential)
# Parallel composition
result = PacketFlow.Intent.Dynamic.compose_intents([
intent1,
intent2,
intent3
], :parallel)
# Conditional composition
result = PacketFlow.Intent.Dynamic.compose_intents([
intent1,
intent2,
intent3
], :conditional, %{condition: &successful?/1})
Create a composite intent from multiple intents
Examples
composite = PacketFlow.Intent.Dynamic.create_composite_intent([
file_read_intent,
file_process_intent,
file_save_intent
], :sequential)
Create an intent dynamically at runtime
Examples
# Create a file read intent dynamically
intent = PacketFlow.Intent.Dynamic.create_intent(
"FileReadIntent",
%{path: "/path/to/file", user_id: "user123"},
[FileCap.read("/path/to/file")]
)
# Create a composite intent
composite_intent = PacketFlow.Intent.Dynamic.create_composite_intent([
intent1,
intent2,
intent3
], :sequential)
Delegate an intent to another processor
Examples
case PacketFlow.Intent.Dynamic.delegate_intent(intent, target_processor) do
{:ok, delegated_intent} ->
# Intent delegated successfully
{:error, reason} ->
# Handle delegation error
end
Route an intent dynamically based on its type and capabilities
Examples
# Route to appropriate reactor
case PacketFlow.Intent.Dynamic.route_intent(intent) do
{:ok, target_reactor} ->
PacketFlow.Reactor.process(target_reactor, intent)
{:error, reason} ->
Logger.error("Failed to route intent: " <> inspect(reason))
end
Transform an intent using registered transformation plugins
Examples
case PacketFlow.Intent.Dynamic.transform_intent(intent) do
{:ok, transformed_intent} ->
# Process transformed intent
{:error, reason} ->
# Handle transformation error
end
Validate an intent using registered validation plugins
Examples
case PacketFlow.Intent.Dynamic.validate_intent(intent) do
{:ok, validated_intent} ->
# Process validated intent
{:error, validation_errors} ->
# Handle validation errors
end