Scaidome.Channels
1.2.2
dotnet add package Scaidome.Channels --version 1.2.2
NuGet\Install-Package Scaidome.Channels -Version 1.2.2
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="Scaidome.Channels" Version="1.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Scaidome.Channels" Version="1.2.2" />
<PackageReference Include="Scaidome.Channels" />
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 Scaidome.Channels --version 1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Scaidome.Channels, 1.2.2"
#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 Scaidome.Channels@1.2.2
#: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=Scaidome.Channels&version=1.2.2
#tool nuget:?package=Scaidome.Channels&version=1.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Scaidome.Channels
Action queues: unbounded in-memory queues that any number of producers add to and a single loop drains. A queue counts the items added and taken and publishes those counts as metrics. It knows nothing about what the items are.
Depends on Scaidome.Abstractions for the metrics abstraction. Namespace: Scaidome.Channels.
Usage
using var queue = new ActionQueue<MyMessage>(
"security-engine",
new UnboundedChannelOptions { SingleReader = true },
meterFactory); // optional
// Producers
queue.Writer.TryWrite(message);
// The one loop that drains it
await foreach (var item in queue.Reader.ReadAllAsync(cancellationToken))
{
Handle(item);
}
// The owner ends the queue through its writer
queue.Writer.Complete();
Behaviour
- The options pass through unchanged.
SingleReaderandSingleWriterare hints to the channel. The queue neither enforces nor changes them, because its counters are safe whatever the hints say. - Each item is counted once. The reader counts in its single-item take, and the platform builds every other way of reading (async reads, enumeration) on that take. The writer counts only items the channel accepts, so a refused or cancelled write counts nothing.
- Peeking is not offered, although the underlying channel could support it.
- The counts are lock-free. Each one is a single atomic increment. Written and read are read separately, never as one snapshot, so the depth can briefly show a negative number.
- Without a meter factory, the instruments go to a meter that does nothing, and the measurements are never evaluated. If the factory fails to create its meter, creating the queue fails with the factory's own error.
- Disposing only unpublishes the metrics. It doesn't complete the channel: queued items stay queued, and the reader, writer and counts keep working. The owner completes the queue through its writer.
Metrics
All instruments are on the meter Scaidome.Channels (version 1.0) and carry a channel tag with the queue's name.
| Instrument | Kind | Meaning |
|---|---|---|
scai.channel.depth |
Observable gauge | Items written but not yet read |
scai.channel.written |
Observable counter | Items accepted in total |
scai.channel.read |
Observable counter | Items taken in total |
The names are public constants on ActionQueue<T>.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Scaidome.Abstractions (>= 1.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.