Registry and factory for creating Source and Destination transports.
More...
#include <dfx-graph/TransportFactory.hpp>
|
| | TransportFactory () |
| | Default constructor.
|
| void | registerBuilder (std::string scheme, SourceBuilder sourceBuilder, DestinationBuilder destinationBuilder) |
| | Register new builders for a specific scheme into the factory.
|
| Core::SourceTransportPtr | createSource (std::string_view uri, nlohmann::json config, Controller &controller) |
| | Creates a SourceTransport based on a URI string.
|
| Core::SourceTransportPtr | createSource (Core::Endpoint::Descriptor descriptor, nlohmann::json config, Controller &controller) |
| | Creates a SourceTransport based on a Core::Endpoint::Descriptor.
|
| Core::DestinationTransportPtr | createDestination (std::string_view uri, nlohmann::json config, Controller &controller) |
| | Creates a DestinationTransport based on a URI string.
|
| Core::DestinationTransportPtr | createDestination (Core::Endpoint::Descriptor descriptor, nlohmann::json config, Controller &controller) |
| | Creates a DestinationTransport based on a Core::Endpoint::Descriptor.
|
Registry and factory for creating Source and Destination transports.
The TransportFactory is responsible for translating URI-like endpoint strings (e.g., "mq:///dfx-queue/node.port" or "local_node.port") into concrete dfx::Core::Transport instances.
- URI Interpretation
- The factory parses strings using descriptorFromString into four segments:
- Scheme: The protocol (e.g., "mq", "tcp", "shm"). If missing, "local" is assumed.
- Address: Optional metadata for remote transports (e.g., the MQ path).
- Node: The target node.
- Port: The target port.
- See also
- dfx::Core::Transport, dfx::Core::Endpoint
◆ DestinationBuilder
Function signature for creating a destination transport.
- Parameters
-
| endpoint | The resolved endpoint descriptor. |
| config | The JSON configuration block for this specific transport. |
◆ SourceBuilder
Function signature for creating a source transport.
- Parameters
-
| endpoint | The resolved endpoint descriptor. |
| config | The JSON configuration block for this specific transport. |
◆ TransportFactory()
| dfx::Graph::TransportFactory::TransportFactory |
( |
| ) |
|
Default constructor.
Registers built-in transports (Local, MQ, etc.) into the internal builders map.
◆ createDestination() [1/2]
Creates a DestinationTransport based on a Core::Endpoint::Descriptor.
- Parameters
-
| descriptor | The descriptor of this transport. |
| config | The additional transport configuration JSON. |
| controller | The controller used to resolve local port references. |
- Returns
- A unique pointer to the constructed DestinationTransport.
- Exceptions
-
◆ createDestination() [2/2]
| Core::DestinationTransportPtr dfx::Graph::TransportFactory::createDestination |
( |
std::string_view | uri, |
|
|
nlohmann::json | config, |
|
|
Controller & | controller ) |
Creates a DestinationTransport based on a URI string.
Performs the same resolution logic as createSource but utilizes the DestinationBuilder registry.
- Parameters
-
| uri | The URI string (e.g., "node.in"). |
| config | The additional transport configuration JSON. |
| controller | The controller used to resolve local port references. |
- Returns
- A unique pointer to the constructed DestinationTransport.
- Exceptions
-
◆ createSource() [1/2]
Creates a SourceTransport based on a Core::Endpoint::Descriptor.
- Parameters
-
| descriptor | The descriptor of this transport. |
| config | The additional transport configuration JSON. |
| controller | The controller used to resolve local port references. |
- Returns
- A unique pointer to the constructed SourceTransport.
- Exceptions
-
◆ createSource() [2/2]
Creates a SourceTransport based on a URI string.
This method:
- Parses the
uri to find the scheme.
- Resolves the Core::Endpoint (mapping local strings to Core::Port pointers via the
controller).
- Selects the appropriate SourceBuilder.
- Instantiates and returns the transport.
- Parameters
-
| uri | The URI string (e.g., "mq:///path/node.port"). |
| config | The additional transport configuration JSON. |
| controller | The controller used to resolve local port references. |
- Returns
- A unique pointer to the constructed SourceTransport.
- Exceptions
-
◆ descriptorFromString()
Parses a URI-like string into an endpoint descriptor.
Examples:
- "node.port" -> scheme: "local", node: "node", port: "port"
- "mq:///queue/node.port" -> scheme: "mq", address: "/queue", node: "node", port: "port"
- Parameters
-
| str | The string to parse (e.g., "node_name.port_name", "mq:///dfx-message-queue/node_name.port_name"). |
- Returns
- A descriptor containing the scheme, node, and port segments.
◆ endpointFromDescriptor()
Converts a descriptor into a concrete Endpoint.
- Parameters
-
| desc | The descriptor produced by descriptorFromString. |
| port | Optional pointer to the resolved port object (Required if desc is local). |
- Returns
- A
Core::Endpoint ready for channel construction.
◆ registerBuilder()
Register new builders for a specific scheme into the factory.
The scheme must not already be registered in the factory or an exception will be throw.
- Parameters
-
The documentation for this class was generated from the following file: