diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b641b10..c29b5ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,12 +32,15 @@ jobs: build_and_test: needs: prepare_versions runs-on: ubuntu-latest + strategy: + matrix: + dotnet-version: ['7.0.x', '8.0.x'] steps: - uses: actions/checkout@v2 - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '8.0.x' + dotnet-version: ${{ matrix.dotnet-version }} - name: Build (Conditional Versioning) run: | if [ "${{ github.event_name }}" = "pull_request" ] || [ "${{ github.event_name }}" = "push" ]; then @@ -60,12 +63,15 @@ jobs: needs: [prepare_versions, build_and_test] if: github.event_name == 'push' runs-on: ubuntu-latest + strategy: + matrix: + dotnet-version: ['7.0.x', '8.0.x'] steps: - uses: actions/checkout@v2 - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '8.0.x' + dotnet-version: ${{ matrix.dotnet-version }} - name: Download Artifacts uses: actions/download-artifact@v2 with: @@ -79,12 +85,15 @@ jobs: needs: [prepare_versions, build_and_test] if: github.event_name == 'release' runs-on: ubuntu-latest + strategy: + matrix: + dotnet-version: ['7.0.x', '8.0.x'] steps: - uses: actions/checkout@v2 - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '8.0.x' + dotnet-version: ${{ matrix.dotnet-version }} - name: Download Artifacts uses: actions/download-artifact@v2 with: diff --git a/Directory.Build.props b/Directory.Build.props index 7c69a52..92a5ce7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,6 @@ - net8.0 + net7.0;net8.0 enable enable diff --git a/Frank.PulseFlow.Tests.Cli/TextPulseFlow.cs b/Frank.PulseFlow.Tests.Cli/TextPulseFlow.cs index 74b8201..75a8036 100644 --- a/Frank.PulseFlow.Tests.Cli/TextPulseFlow.cs +++ b/Frank.PulseFlow.Tests.Cli/TextPulseFlow.cs @@ -1,11 +1,18 @@ namespace Frank.PulseFlow.Tests.Cli; -public class TextPulseFlow(ILogger logger) : IPulseFlow +public class TextPulseFlow : IPulseFlow { + private readonly ILogger _logger; + + public TextPulseFlow(ILogger logger) + { + _logger = logger; + } + public async Task HandleAsync(IPulse message, CancellationToken cancellationToken) { if (message is TextPulse textMessage) - logger.LogInformation("Received text message: {Text}", textMessage.Text); + _logger.LogInformation("Received text message: {Text}", textMessage.Text); await Task.CompletedTask; } diff --git a/Frank.PulseFlow/Frank.PulseFlow.csproj b/Frank.PulseFlow/Frank.PulseFlow.csproj index 552c438..79a27af 100644 --- a/Frank.PulseFlow/Frank.PulseFlow.csproj +++ b/Frank.PulseFlow/Frank.PulseFlow.csproj @@ -2,13 +2,16 @@ true - false Library PulseFlow uses Channel -mechanism for internal messaging - Pulse,Flow,PulseFlow + Pulse,Flow,PulseFlow,Frank,Frank Haugen,Messaging,In-Memory - Initial release + + 2023-12-14: + 1.0 Initial release of PulseFlow + 1.1 Added support for .NET 7.0 and .NET 8.0 + true $(NoWarn);1591 @@ -30,8 +33,14 @@ git - - + + + + + + + + diff --git a/Frank.PulseFlow/Internal/Conduit.cs b/Frank.PulseFlow/Internal/Conduit.cs index 9980597..005a23f 100644 --- a/Frank.PulseFlow/Internal/Conduit.cs +++ b/Frank.PulseFlow/Internal/Conduit.cs @@ -1,9 +1,16 @@ namespace Frank.PulseFlow.Internal; -internal class Conduit(IChannel messageChannel) : IConduit +internal class Conduit : IConduit { + private readonly IChannel _messageChannel; + + public Conduit(IChannel messageChannel) + { + _messageChannel = messageChannel; + } + public Task SendAsync(IPulse message) { - return messageChannel.SendAsync(message); + return _messageChannel.SendAsync(message); } } \ No newline at end of file diff --git a/Frank.PulseFlow/Internal/PulseNexus.cs b/Frank.PulseFlow/Internal/PulseNexus.cs index eca55cf..c863048 100644 --- a/Frank.PulseFlow/Internal/PulseNexus.cs +++ b/Frank.PulseFlow/Internal/PulseNexus.cs @@ -2,12 +2,21 @@ namespace Frank.PulseFlow.Internal; -internal class PulseNexus(IChannel channel, IEnumerable pulseFlows) : BackgroundService +internal class PulseNexus : BackgroundService { + private readonly IChannel _channel; + private readonly IEnumerable _pulseFlows; + + public PulseNexus(IChannel channel, IEnumerable pulseFlows) + { + _channel = channel; + _pulseFlows = pulseFlows; + } + protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - await foreach (IPulse pulse in channel.ReadAllAsync(stoppingToken)) - await Task.WhenAll(pulseFlows + await foreach (IPulse pulse in _channel.ReadAllAsync(stoppingToken)) + await Task.WhenAll(_pulseFlows .Where(x => x.CanHandle(pulse.GetType())) .Select(flow => flow.HandleAsync(pulse, stoppingToken))); } diff --git a/Frank.PulseFlow/PulseFlowBuilder.cs b/Frank.PulseFlow/PulseFlowBuilder.cs index 2b3a467..50fadc7 100644 --- a/Frank.PulseFlow/PulseFlowBuilder.cs +++ b/Frank.PulseFlow/PulseFlowBuilder.cs @@ -2,8 +2,15 @@ namespace Frank.PulseFlow; -public class PulseFlowBuilder(IServiceCollection services) : IPulseFlowBuilder +public class PulseFlowBuilder : IPulseFlowBuilder { + private readonly IServiceCollection _services; + + public PulseFlowBuilder(IServiceCollection services) + { + _services = services; + } + /// /// Adds a flow of type T to the pulse flow builder. /// @@ -11,7 +18,7 @@ public class PulseFlowBuilder(IServiceCollection services) : IPulseFlowBuilder /// The pulse flow builder instance. public IPulseFlowBuilder AddFlow() where T : class, IPulseFlow { - services.AddTransient(); + _services.AddTransient(); return this; } } \ No newline at end of file diff --git a/Frank.PulseFlow/README.md b/Frank.PulseFlow/README.md index 3184d88..4deef0b 100644 --- a/Frank.PulseFlow/README.md +++ b/Frank.PulseFlow/README.md @@ -1,5 +1,21 @@ # PulseFlow Local Messaging +PulseFlow Local Messaging is a lightweight, high-performance messaging system that enables seamless communication + +## Table of Contents + +- [Overview](#overview) + - [Key Features](#key-features) + - [Illustration](#illustration) + - [Use Cases](#use-cases) +- [Getting Started](#getting-started) + - [Installation](#installation) +- [Concepts](#concepts) + - [Nexus](#nexus) + - [Conduit](#conduit) + - [Pulse](#pulse) + - [PulseFlow](#pulseflow) + ## Overview PulseFlow Local Messaging is a lightweight, high-performance messaging system that enables seamless communication