Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the project multitargeted #1

Merged
merged 6 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
11 changes: 9 additions & 2 deletions Frank.PulseFlow.Tests.Cli/TextPulseFlow.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
namespace Frank.PulseFlow.Tests.Cli;

public class TextPulseFlow(ILogger<TextPulseFlow> logger) : IPulseFlow
public class TextPulseFlow : IPulseFlow
{
private readonly ILogger<TextPulseFlow> _logger;

public TextPulseFlow(ILogger<TextPulseFlow> 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;
}

Expand Down
19 changes: 14 additions & 5 deletions Frank.PulseFlow/Frank.PulseFlow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

<PropertyGroup>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<OutputType>Library</OutputType>

<Description>PulseFlow uses Channel -mechanism for internal messaging</Description>
<PackageTags>Pulse,Flow,PulseFlow</PackageTags>
<PackageTags>Pulse,Flow,PulseFlow,Frank,Frank Haugen,Messaging,In-Memory</PackageTags>

<PackageReleaseNotes>Initial release</PackageReleaseNotes>
<PackageReleaseNotes>
2023-12-14:
1.0 Initial release of PulseFlow
1.1 Added support for .NET 7.0 and .NET 8.0
</PackageReleaseNotes>

<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
Expand All @@ -30,8 +33,14 @@
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0"/>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" Condition="'$(TargetFramework)' == 'net8.0'"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" Condition="'$(TargetFramework)' == 'net7.0'"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="7.0.0" PrivateAssets="All" Condition="'$(TargetFramework)' == 'net7.0'"/>
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 9 additions & 2 deletions Frank.PulseFlow/Internal/Conduit.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
15 changes: 12 additions & 3 deletions Frank.PulseFlow/Internal/PulseNexus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@

namespace Frank.PulseFlow.Internal;

internal class PulseNexus(IChannel channel, IEnumerable<IPulseFlow> pulseFlows) : BackgroundService
internal class PulseNexus : BackgroundService
{
private readonly IChannel _channel;
private readonly IEnumerable<IPulseFlow> _pulseFlows;

public PulseNexus(IChannel channel, IEnumerable<IPulseFlow> 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)));
}
Expand Down
11 changes: 9 additions & 2 deletions Frank.PulseFlow/PulseFlowBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

namespace Frank.PulseFlow;

public class PulseFlowBuilder(IServiceCollection services) : IPulseFlowBuilder
public class PulseFlowBuilder : IPulseFlowBuilder
{
private readonly IServiceCollection _services;

public PulseFlowBuilder(IServiceCollection services)
{
_services = services;
}

/// <summary>
/// Adds a flow of type T to the pulse flow builder.
/// </summary>
/// <typeparam name="T">The type of the flow to be added.</typeparam>
/// <returns>The pulse flow builder instance.</returns>
public IPulseFlowBuilder AddFlow<T>() where T : class, IPulseFlow
{
services.AddTransient<IPulseFlow, T>();
_services.AddTransient<IPulseFlow, T>();
return this;
}
}
16 changes: 16 additions & 0 deletions Frank.PulseFlow/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading