FractalDataWorks.Services.Connections.Abstractions 0.9.5-alpha.1008

This is a prerelease version of FractalDataWorks.Services.Connections.Abstractions.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FractalDataWorks.Services.Connections.Abstractions" Version="0.9.5-alpha.1008" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FractalDataWorks.Services.Connections.Abstractions" Version="0.9.5-alpha.1008" />
                    
Directory.Packages.props
<PackageReference Include="FractalDataWorks.Services.Connections.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FractalDataWorks.Services.Connections.Abstractions --version 0.9.5-alpha.1008
                    
#r "nuget: FractalDataWorks.Services.Connections.Abstractions, 0.9.5-alpha.1008"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FractalDataWorks.Services.Connections.Abstractions@0.9.5-alpha.1008
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FractalDataWorks.Services.Connections.Abstractions&version=0.9.5-alpha.1008&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FractalDataWorks.Services.Connections.Abstractions&version=0.9.5-alpha.1008&prerelease
                    
Install as a Cake Tool

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: IGenericConnectionService extends IServiceType
  • Command Contract: IConnectionCommand defines connection command structure
  • Configuration Base: IGenericConnectionConfiguration provides 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 identifier
    • CreatedAt - Timestamp
    • CommandType - 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 identifier
    • Query - LINQ expression for filtering
    • CommandType - Type of data operation
    • TargetContainer - Table/collection name
    • Metadata - Additional command metadata
    • Timeout - 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:

  1. Implement IGenericConnectionService with capability metadata
  2. Inherit from GenericConnectionProviderBase for service enumeration
  3. Create connection factory that produces actual connections
  4. Define connection types with proper state management
  5. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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