ProSol.Messaging
4.0.0-rc.1
See the version list below for details.
dotnet add package ProSol.Messaging --version 4.0.0-rc.1
NuGet\Install-Package ProSol.Messaging -Version 4.0.0-rc.1
<PackageReference Include="ProSol.Messaging" Version="4.0.0-rc.1" />
paket add ProSol.Messaging --version 4.0.0-rc.1
#r "nuget: ProSol.Messaging, 4.0.0-rc.1"
// Install ProSol.Messaging as a Cake Addin #addin nuget:?package=ProSol.Messaging&version=4.0.0-rc.1&prerelease // Install ProSol.Messaging as a Cake Tool #tool nuget:?package=ProSol.Messaging&version=4.0.0-rc.1&prerelease
ProSol.Messaging
Implements a message broker with ability to build a pipeline of listeners.
API
The project contains an API for the Observer pattern
: IPublisher
, ISubscriber
, and PipelinePublisher
.
- The
IPublisher
interface is aimed to provide a layer of absctraction to the client. - The
ISubscriber
interface decalres a subscription contract with chained calls support viaNextDelegate
.NextDelegate
: is a mandatory delegate to trigger if current subscriber wants to bypass a message to next subscriber.
PipelinePublisher
: a ready-to-use implementation for chained subscriptions.
Demo
Let's see how works in a console app, by making a publisher for strings, which addresses the message to the StringListener, but there is a StringLimitListener between them.
So, the StringLimitListener will drop the message longer than "Please" string:
using ProSol.Messaging;
var maxLength = "Please".Length + 1;
var broker = new MessageBroker<string>();
// Set up a chain.
broker.Subscribe(new StringLimitListener(maxLength));
broker.Subscribe(new StringListener());
// Push some messages.
broker.Publish("Please");
broker.Publish("STOP");
broker.Publish("The planet");
// OUTPUT:
// Please
// STOP
// Clean up.
broker.Complete();
public class StringListener : ISubscriber<string>
{
public void OnCompleted() { }
public void OnNext(string message, NextDelegate next)
{
Console.WriteLine(message);
if (message != "STOP")
{
next();
}
}
}
public class StringLimitListener(int limit) : ISubscriber<string>
{
private readonly int limit = limit;
public void OnCompleted() { }
public void OnNext(string message, NextDelegate next)
{
if (message.Length < limit)
{
next();
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ProSol.Messaging:
Package | Downloads |
---|---|
ProSol.Html.TagsProvider
TagsProvider is a tool for extracting HTML tags from a string, in event-driven way. Helps to extract text, structured data, from a specific site. |
|
ProSol.WebScrap
A HTML parser, for extracting the text from a web pages, with CSS selectors. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.0 | 486 | 12/8/2023 |
4.0.0-rc.9.0 | 86 | 12/7/2023 |
4.0.0-rc.8.0 | 72 | 12/7/2023 |
4.0.0-rc.7.4 | 78 | 12/5/2023 |
4.0.0-rc.7.3 | 69 | 12/5/2023 |
4.0.0-rc.7.2 | 76 | 12/5/2023 |
4.0.0-rc.7.1 | 78 | 12/5/2023 |
4.0.0-rc.7.0 | 76 | 12/5/2023 |
4.0.0-rc.6.0 | 89 | 12/2/2023 |
4.0.0-rc.5.1 | 80 | 11/30/2023 |
4.0.0-rc.5.0 | 75 | 11/30/2023 |
4.0.0-rc.3.0 | 80 | 11/24/2023 |
4.0.0-rc.2 | 79 | 11/24/2023 |
4.0.0-rc.1 | 82 | 11/24/2023 |
3.0.1 | 178 | 11/24/2023 |
3.0.0 | 166 | 11/22/2023 |
3.0.0-rc.0.2 | 77 | 11/21/2023 |
3.0.0-rc.0.1 | 73 | 11/20/2023 |
2.0.0 | 144 | 11/19/2023 |
1.0.0 | 126 | 11/16/2023 |