FractalDataWorks.Services.Connections.Abstractions
0.9.5-alpha.1008
dotnet add package FractalDataWorks.Services.Connections.Abstractions --version 0.9.5-alpha.1008
NuGet\Install-Package FractalDataWorks.Services.Connections.Abstractions -Version 0.9.5-alpha.1008
<PackageReference Include="FractalDataWorks.Services.Connections.Abstractions" Version="0.9.5-alpha.1008" />
<PackageVersion Include="FractalDataWorks.Services.Connections.Abstractions" Version="0.9.5-alpha.1008" />
<PackageReference Include="FractalDataWorks.Services.Connections.Abstractions" />
paket add FractalDataWorks.Services.Connections.Abstractions --version 0.9.5-alpha.1008
#r "nuget: FractalDataWorks.Services.Connections.Abstractions, 0.9.5-alpha.1008"
#:package FractalDataWorks.Services.Connections.Abstractions@0.9.5-alpha.1008
#addin nuget:?package=FractalDataWorks.Services.Connections.Abstractions&version=0.9.5-alpha.1008&prerelease
#tool nuget:?package=FractalDataWorks.Services.Connections.Abstractions&version=0.9.5-alpha.1008&prerelease
FractalDataWorks.Services.Connections.Abstractions
Minimal external connection service abstractions for the FractalDataWorks Framework.
Purpose
This package provides the foundational interfaces for external connection services in the FractalDataWorks ecosystem. It defines the domain boundary for connection management through minimal, clean abstractions.
Architecture
The external connections abstractions follow the framework's enhanced service pattern:
- Core Interface:
IGenericConnectionServiceextendsIServiceType - Command Contract:
IConnectionCommanddefines connection command structure - Configuration Base:
IGenericConnectionConfigurationprovides configuration contract - Base Classes: Add type constraints without implementation logic
Command Architecture
This package defines two distinct command hierarchies for the two-tier architecture:
IConnectionCommand (Service-Level)
Service-level commands for connection management:
- Purpose: Creating and configuring connections, testing connectivity, discovery operations, connection lifecycle management
- Key Properties:
CommandId- Unique command identifierCreatedAt- TimestampCommandType- Type of connection operation
- Scope: Connection service infrastructure
IDataCommand (Data-Level)
Data-level commands executed through connections (defined in FractalDataWorks.Data.Abstractions):
- Purpose: Query operations, insert/update/delete operations, bulk operations, schema discovery
- Key Properties:
ConnectionName- Target connection identifierQuery- LINQ expression for filteringCommandType- Type of data operationTargetContainer- Table/collection nameMetadata- Additional command metadataTimeout- Operation timeout
- Scope: Data operations through established connections
Important: These are separate command hierarchies. Service commands manage connections, while data commands operate through established connections. Do not confuse the two.
Key Interfaces
Core Service Interface
public interface IGenericConnectionService : IServiceType
{
// Service discovery and capability information
string[] SupportedDataStores { get; }
string ProviderName { get; }
Type ConnectionType { get; }
Type ConfigurationType { get; }
IReadOnlyList<string> SupportedConnectionModes { get; }
int Priority { get; }
// Factory creation for connections
Task<IGenericResult<IGenericConnectionFactory>> CreateConnectionFactoryAsync(
IServiceProvider serviceProvider);
// Validation and metadata
IGenericResult ValidateCapability(string dataStore, string? connectionMode = null);
Task<IGenericResult<IProviderMetadata>> GetProviderMetadataAsync();
}
Generic Service Interface
public interface IGenericConnectionService<TConfiguration> : IGenericConnectionService
where TConfiguration : IGenericConnectionConfiguration, new()
{
// Type-safe factory creation
Task<IGenericResult<IGenericConnectionFactory<TConfiguration, IGenericConnection<TConfiguration>>>>
CreateTypedConnectionFactoryAsync(IServiceProvider serviceProvider);
// Configuration validation
IGenericResult ValidateConfiguration(TConfiguration configuration);
}
Connection Interface (Built-In Translator Pattern)
public interface IGenericConnection
{
// Connection lifecycle and state management
string ConnectionId { get; }
string ProviderName { get; }
GenericConnectionState State { get; }
string ConnectionString { get; }
// Connection operations
Task<IGenericResult> OpenAsync();
Task<IGenericResult> CloseAsync();
Task<IGenericResult> TestConnectionAsync();
Task<IGenericResult<IConnectionMetadata>> GetMetadataAsync();
// Data command execution (Built-In Translator Pattern)
// Connection owns translator and handles translation internally
Task<IGenericResult<T>> Execute<T>(IDataCommand command, CancellationToken cancellationToken = default);
}
Factory Interface
public interface IGenericConnectionFactory
{
// Connection creation and validation
string ProviderName { get; }
IReadOnlyList<string> SupportedConnectionTypes { get; }
Type ConfigurationType { get; }
Task<IGenericResult<IGenericConnection>> CreateConnectionAsync(FractalConfigurationBase configuration);
Task<IGenericResult> ValidateConfiguration(FractalConfigurationBase configuration);
Task<IGenericResult> TestConnectivityAsync(FractalConfigurationBase configuration);
}
Built-In Translator Pattern
Key Principle: Connections own their translators. No separate translator provider needed.
Two Connection Patterns
1. Deterministic Pattern (SQL Databases)
- Use Case: Single translator per connection type
- Example: SQL Server connection always uses MsSqlTranslator
- Implementation: Translator injected via constructor DI
public sealed class MsSqlConnection : IDataConnection
{
private readonly IDataCommandTranslator _translator;
private readonly SqlConnection _sqlConnection;
private readonly ILogger<MsSqlConnection> _logger;
// Translator injected via DI (deterministic - always MsSqlTranslator)
public MsSqlConnection(
IDataCommandTranslator translator,
MsSqlConnectionConfig config,
ILogger<MsSqlConnection> logger)
{
_translator = translator;
_sqlConnection = new SqlConnection(config.ConnectionString);
_logger = logger;
}
public async Task<IGenericResult<T>> Execute<T>(IDataCommand command, CancellationToken ct = default)
{
// 1. Translate using owned translator
var translatedResult = await _translator.TranslateAsync(command, ct);
if (!translatedResult.IsSuccess) return GenericResult<T>.Failure(translatedResult.Message);
// 2. Execute translated SQL command
return await ExecuteSqlCommand<T>(translatedResult.Value, ct);
}
}
DI Registration (Deterministic):
public override void Register(IServiceCollection services)
{
// Register translator - single implementation
services.AddScoped<IDataCommandTranslator, MsSqlDataCommandTranslator>();
// Register connection - translator auto-injected
services.AddScoped<IDataConnection, MsSqlConnection>();
}
2. Flexible Pattern (HTTP Connections)
- Use Case: Multiple translators per connection type
- Example: HTTP connection supports REST, GraphQL, OData translators
- Implementation: Factory selects translator based on config.TranslatorLanguage
public sealed class HttpConnection : IDataConnection
{
private readonly IDataCommandTranslator _translator;
private readonly HttpClient _httpClient;
private readonly ILogger<HttpConnection> _logger;
// Translator selected by factory based on config.TranslatorLanguage
public HttpConnection(
HttpConnectionConfig config,
IDataCommandTranslatorFactory translatorFactory,
IHttpClientFactory httpClientFactory,
ILogger<HttpConnection> logger)
{
// Factory selects translator: "Rest", "GraphQL", "OData", etc.
_translator = translatorFactory.GetTranslator(config.TranslatorLanguage);
_httpClient = httpClientFactory.CreateClient(config.ClientName);
_logger = logger;
}
public async Task<IGenericResult<T>> Execute<T>(IDataCommand command, CancellationToken ct = default)
{
// 1. Translate using owned translator
var translatedResult = await _translator.TranslateAsync(command, ct);
if (!translatedResult.IsSuccess) return GenericResult<T>.Failure(translatedResult.Message);
// 2. Execute translated HTTP request
return await ExecuteHttpCommand<T>(translatedResult.Value, ct);
}
}
Configuration (Flexible):
{
"Connections": {
"RestApi": {
"Type": "Http",
"BaseUrl": "https://api.example.com",
"TranslatorLanguage": "Rest" // Factory selects RestTranslator
},
"GraphQLApi": {
"Type": "Http",
"BaseUrl": "https://graphql.example.com/query",
"TranslatorLanguage": "GraphQL" // Factory selects GraphQLTranslator
}
}
}
DI Registration (Flexible):
public override void Register(IServiceCollection services)
{
// Register all supported translators
services.AddScoped<RestDataCommandTranslator>();
services.AddScoped<GraphQLDataCommandTranslator>();
services.AddScoped<ODataCommandTranslator>();
// Register translator factory
services.AddScoped<IDataCommandTranslatorFactory, HttpDataCommandTranslatorFactory>();
// Register connection - factory auto-injected, selects translator based on config
services.AddScoped<IDataConnection, HttpConnection>();
}
Translator Factory (Flexible):
public sealed class HttpDataCommandTranslatorFactory : IDataCommandTranslatorFactory
{
private readonly IServiceProvider _serviceProvider;
public HttpDataCommandTranslatorFactory(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public IDataCommandTranslator GetTranslator(string translatorLanguage)
{
return translatorLanguage switch
{
"Rest" => _serviceProvider.GetRequiredService<RestDataCommandTranslator>(),
"GraphQL" => _serviceProvider.GetRequiredService<GraphQLDataCommandTranslator>(),
"OData" => _serviceProvider.GetRequiredService<ODataCommandTranslator>(),
_ => throw new NotSupportedException($"Translator language '{translatorLanguage}' not supported")
};
}
}
Base Classes
The package includes base classes that only add generic type constraints:
GenericConnectionProviderBase- Provides service type implementation with metadata- Base classes are logging-enabled but contain no business logic
Important: Base classes contain no implementation logic. They exist solely to provide service type enumeration support and type constraints.
Core Types
Connection State Management
public enum GenericConnectionState
{
Closed, Opening, Open, Closing, Broken, Connecting, Executing
}
Connection Metadata
public interface IConnectionMetadata
{
// Connection information and capabilities
// Version, features, performance characteristics
}
public interface IProviderMetadata
{
// Provider capabilities and information
// Version, supported features, limitations
}
Enhanced Service Pattern
Unlike other abstractions, external connections use an enhanced service pattern:
- Rich Interface: More than just command processing
- Service Discovery: Built-in capability advertisement
- Factory Pattern: Separate connection creation from service
- Metadata Support: Runtime capability querying
- Type Safety: Generic constraints for configurations
This pattern is necessary because connections are infrastructure services that need:
- Runtime capability discovery
- Dynamic service selection
- Type-safe configuration handling
- Connection lifecycle management
Usage
Concrete implementations should:
- Implement IGenericConnectionService with capability metadata
- Inherit from GenericConnectionProviderBase for service enumeration
- Create connection factory that produces actual connections
- Define connection types with proper state management
- Provide configuration classes for connection parameters
Generic Constraints
The type hierarchy flows from service discovery to typed implementation:
IServiceType
↓
IGenericConnectionService
↓
IGenericConnectionService<TConfiguration>
↓
GenericConnectionProviderBase
↓
ConcreteConnectionService<SpecificConfig>
Framework Integration
This abstraction integrates with other FractalDataWorks services:
- DataGateways: Provides database connections for data services
- SecretManager: Retrieves connection strings and credentials
- Authentication: Handles connection authentication
- Configuration: Manages connection settings and parameters
Design Philosophy
These abstractions balance minimal design with practical needs:
- ✅ Define domain boundaries through interfaces
- ✅ Provide rich service discovery capabilities
- ✅ Enable dynamic service selection at runtime
- ✅ Support multiple connection types per service
- ❌ No implementation logic in abstractions
- ❌ No complex inheritance hierarchies
- ❌ No framework-specific coupling beyond service types
Evolution
This package will grow organically as the framework evolves:
- New connection types added when needed
- Enhanced metadata interfaces for better discovery
- Additional factory patterns for complex scenarios
- Backward compatibility maintained for existing implementations
The enhanced service design provides the flexibility needed for infrastructure services while maintaining the framework's consistency and type safety principles.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- FractalDataWorks.Collections (>= 0.9.5-alpha.1008)
- FractalDataWorks.Commands.Abstractions (>= 0.9.5-alpha.1008)
- FractalDataWorks.Commands.Data.Abstractions (>= 0.9.5-alpha.1008)
- FractalDataWorks.Data.Abstractions (>= 0.9.5-alpha.1008)
- FractalDataWorks.Data.DataSets.Abstractions (>= 0.9.5-alpha.1008)
- FractalDataWorks.MessageLogging.Abstractions (>= 0.9.5-alpha.1008)
- FractalDataWorks.Results (>= 0.9.5-alpha.1008)
- FractalDataWorks.Services.Abstractions (>= 0.9.5-alpha.1008)
- FractalDataWorks.ServiceTypes (>= 0.9.5-alpha.1008)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0-rc.2.25502.107)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0-rc.2.25502.107)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-rc.2.25502.107)
NuGet packages (13)
Showing the top 5 NuGet packages that depend on FractalDataWorks.Services.Connections.Abstractions:
| Package | Downloads |
|---|---|
|
FractalDataWorks.Services
Development tools and utilities for the FractalDataWorks ecosystem. Build: |
|
|
FractalDataWorks.Data.Execution
Development tools and utilities for the FractalDataWorks ecosystem. Build: |
|
|
FractalDataWorks.Services.Connections
Development tools and utilities for the FractalDataWorks ecosystem. Build: |
|
|
FractalDataWorks.Services.Data
Development tools and utilities for the FractalDataWorks ecosystem. Build: |
|
|
FractalDataWorks.Services.Connections.MsSql
Development tools and utilities for the FractalDataWorks ecosystem. Build: |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.9.5-alpha.1008 | 0 | 11/25/2025 |
| 0.9.5-alpha.1007 | 0 | 11/25/2025 |
| 0.9.5-alpha.1006 | 0 | 11/25/2025 |
| 0.9.1-alpha.1037 | 0 | 11/25/2025 |
| 0.9.1-alpha.1036 | 0 | 11/25/2025 |
| 0.9.1-alpha.1035 | 0 | 11/25/2025 |
| 0.9.1-alpha.1033 | 0 | 11/25/2025 |
| 0.9.0-alpha.1011.ged0a6c6e98 | 355 | 11/18/2025 |
| 0.9.0-alpha.1010.gecd88aac50 | 346 | 11/18/2025 |
| 0.9.0-alpha.1009.g7f6817e985 | 350 | 11/18/2025 |
| 0.9.0-alpha.1006.gf287016c0c | 363 | 11/18/2025 |
| 0.8.0-alpha.1011 | 350 | 11/18/2025 |
| 0.7.0-alpha.1022 | 145 | 11/3/2025 |
| 0.7.0-alpha.1021 | 150 | 11/3/2025 |
| 0.7.0-alpha.1008 | 115 | 11/2/2025 |
| 0.7.0-alpha.1006 | 137 | 10/30/2025 |
| 0.7.0-alpha.1005 | 139 | 10/30/2025 |
| 0.7.0-alpha.1004 | 139 | 10/30/2025 |
| 0.7.0-alpha.1001 | 137 | 10/29/2025 |
| 0.6.0-alpha.1006 | 133 | 10/29/2025 |
| 0.6.0-alpha.1005 | 136 | 10/28/2025 |
| 0.6.0-alpha.1004 | 128 | 10/28/2025 |