Moved to Novolis: This library is superseded by `Novolis.Messaging.Channels` from novolis-messaging. This repository is archived; do not add features here.
A tiny library for having Channel<T> as a Dependency Injection resource in a sane manner
Targets .NET 10 (net10.0). The solution file is SLNX (Frank.Channels.DependencyInjection.slnx). For build commands, SDK notes, and design details, see docs/build-and-test.md and docs/library-design.md. Repository guidance for tools and contributors lives in AGENT.md.
using Frank.Channels.DependencyInjection;
// Register the channel of a type as a dependency:
services.AddChannel<string>();
// Use the channel as a dependency in various ways:
var channel = provider.GetRequiredService<Channel<string>>();
var channelWriter = provider.GetRequiredService<ChannelWriter<string>>();
var channelReader = provider.GetRequiredService<ChannelReader<string>>();using Frank.Channels.DependencyInjection;
// Register the channel of a type as a dependency with a custom configuration:
services.AddChannel<string>(options =>
{
options.BoundedCapacity = 100;
options.FullMode = BoundedChannelFullMode.Wait;
options.SingleReader = true;
options.SingleWriter = true;
});
// Use the channel as a dependency in various ways:
var channel = provider.GetRequiredService<Channel<string>>();
var channelWriter = provider.GetRequiredService<ChannelWriter<string>>();
var channelReader = provider.GetRequiredService<ChannelReader<string>>();