The CapabilityClient class in Fabric is responsible for all interactions with the capabilities2 server. It manages service clients for querying available capabilities, establishing bonds, allocating and freeing capabilities, connecting them according to the plan, and triggering execution.
-
Discover available interfaces and providers from the capabilities2 server
-
Establish a bond for plan execution
-
Allocate (use) and free capabilities as required by the plan
-
Connect capabilities according to the parsed plan's connections
-
Trigger the first node to start execution
| Method | Purpose | Related Capability Service |
|---|---|---|
initialize(node) |
Set up service clients, read service names from capability_client.services.*, and wait for each service to become available |
(all services below) |
getInterfaces(capabilities) |
Query all available interfaces and populate the list | /capabilities/get_interfaces |
getSemanticInterfaces(capabilities) |
Query and append semantic interfaces for each capability | /capabilities/get_semantic_interfaces |
getProviders(capabilities) |
Query and set providers and alternatives for each capability | /capabilities/get_providers |
request_bond() |
Establish a bond with the server and return the bond ID | /capabilities/establish_bond |
use_capabilities(plan) |
Request allocation of all capabilities in the plan | /capabilities/use_capability |
free_capabilities(plan) |
Free all started capabilities in the plan | /capabilities/free_capability |
connect_capabilities(plan) |
Configure connections between capabilities as per the plan | /capabilities/connect_capability |
trigger_first_node(plan) |
Trigger the first capability in the plan to start execution | /capabilities/trigger_capability |
-
The Fabric server creates and initializes a
CapabilityClientat startup. -
When a plan is processed, the client:
-
Queries interfaces and providers for all required capabilities.
-
Establishes a bond for the plan.
-
Allocates (uses) all required capabilities.
-
Configures connections between capabilities as specified in the plan's connections.
-
Triggers the first node to start execution.
-
Frees capabilities when the plan is complete or on error.
-
-
Initialization:
initialize(node)sets up all service clients and waits for them to become available. -
Discovery:
getInterfaces()andgetProviders()populate the list of capabilities and their providers. -
Bonding:
request_bond()establishes a bond for the plan. -
Allocation:
use_capabilities(plan)allocates all required capabilities. -
Connection:
connect_capabilities(plan)configures the event-driven connections between capabilities. -
Execution:
trigger_first_node(plan)starts the plan execution. -
Cleanup:
free_capabilities(plan)releases all used capabilities.
-
All service calls are checked for validity and throw
fabric::fabric_exceptionon failure. -
The client waits for each service to become available before proceeding. The wait timeout is controlled by
capability_client.service_wait_timeout_sec. -
If any step fails, capabilities are freed and errors are logged.
The CapabilityClient is a central component for orchestrating the dynamic allocation, connection, and management of capabilities in Fabric, ensuring robust and flexible plan execution.