From 518471d151fcb37beb89c80c5ff556d9b05597b1 Mon Sep 17 00:00:00 2001 From: "Frank R. Haugen" Date: Thu, 14 Dec 2023 17:27:46 +0100 Subject: [PATCH 1/4] Make the project multitargeted --- Directory.Build.props | 2 +- Frank.PulseFlow.Tests.Cli/TextPulseFlow.cs | 11 +++++++++-- Frank.PulseFlow/Frank.PulseFlow.csproj | 17 +++++++++++++---- Frank.PulseFlow/Internal/Conduit.cs | 11 +++++++++-- Frank.PulseFlow/Internal/PulseNexus.cs | 15 ++++++++++++--- Frank.PulseFlow/PulseFlowBuilder.cs | 11 +++++++++-- Frank.PulseFlow/README.md | 16 ++++++++++++++++ 7 files changed, 69 insertions(+), 14 deletions(-) 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..6f83d13 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 From 9c1eba02a32401c96a9dc07034fcc07133c9381f Mon Sep 17 00:00:00 2001 From: "Frank R. Haugen" Date: Thu, 14 Dec 2023 17:38:49 +0100 Subject: [PATCH 2/4] Update main.yml --- .github/workflows/main.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a72a3c4..9b46aa2 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: Restore dependencies run: dotnet restore - name: Build (Conditional Versioning) @@ -62,12 +65,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: @@ -81,12 +87,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: From 1831408659b2aacea10d44607b7f18dd48dfbfa1 Mon Sep 17 00:00:00 2001 From: "Frank R. Haugen" Date: Thu, 14 Dec 2023 17:47:12 +0100 Subject: [PATCH 3/4] ffff --- Frank.PulseFlow/Frank.PulseFlow.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Frank.PulseFlow/Frank.PulseFlow.csproj b/Frank.PulseFlow/Frank.PulseFlow.csproj index 6f83d13..79a27af 100644 --- a/Frank.PulseFlow/Frank.PulseFlow.csproj +++ b/Frank.PulseFlow/Frank.PulseFlow.csproj @@ -34,13 +34,13 @@ - - + + - - + + From 20b51e36bc70de65762e09a31c1541cbc2a3d605 Mon Sep 17 00:00:00 2001 From: "Frank R. Haugen" Date: Thu, 14 Dec 2023 18:39:42 +0100 Subject: [PATCH 4/4] Update main.yml --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3373dbb..c29b5ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,8 +41,6 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: ${{ matrix.dotnet-version }} - - name: Restore dependencies - run: dotnet restore - name: Build (Conditional Versioning) run: | if [ "${{ github.event_name }}" = "pull_request" ] || [ "${{ github.event_name }}" = "push" ]; then