Skip to content

Repository files navigation

Soenneker.Dispatchers.Dispatcher

Provides a marker interface and a logging base class for application-specific dispatchers.

Installation

dotnet add package Soenneker.Dispatchers.Dispatcher

Usage

using Microsoft.Extensions.Logging;
using Soenneker.Dispatchers.Dispatcher;

public sealed class NotificationDispatcher(ILogger<Dispatcher> logger)
    : Dispatcher(logger)
{
    public Task Dispatch(string message, CancellationToken cancellationToken = default)
    {
        Logger.LogInformation("Dispatching notification");
        return Send(message, cancellationToken);
    }

    private static Task Send(string message, CancellationToken cancellationToken) =>
        Task.CompletedTask;
}

Dispatcher only stores the logger and exposes it to derived classes through the protected Logger property. It does not define dispatch methods, select handlers, queue work, manage retries, or register services. Those behaviors and any application-specific interface belong in the derived dispatcher.

All subclasses use the Soenneker.Dispatchers.Dispatcher.Dispatcher logging category because the constructor accepts ILogger<Dispatcher>.

IDispatcher is an empty marker contract. Use it when discovery or registration code needs a common dispatcher type; it does not provide callable members.

About

An abstract base class for Dispatchers, that handles routing across other utilities

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages