DcsvIo.D2.Handler.Abstractions
0.1.1
dotnet add package DcsvIo.D2.Handler.Abstractions --version 0.1.1
NuGet\Install-Package DcsvIo.D2.Handler.Abstractions -Version 0.1.1
<PackageReference Include="DcsvIo.D2.Handler.Abstractions" Version="0.1.1" />
<PackageVersion Include="DcsvIo.D2.Handler.Abstractions" Version="0.1.1" />
<PackageReference Include="DcsvIo.D2.Handler.Abstractions" />
paket add DcsvIo.D2.Handler.Abstractions --version 0.1.1
#r "nuget: DcsvIo.D2.Handler.Abstractions, 0.1.1"
#:package DcsvIo.D2.Handler.Abstractions@0.1.1
#addin nuget:?package=DcsvIo.D2.Handler.Abstractions&version=0.1.1
#tool nuget:?package=DcsvIo.D2.Handler.Abstractions&version=0.1.1
DcsvIo.D2.Handler.Abstractions
Domain-safe slice of the handler stack: IHandler<in TInput, TOutput>, IHandlerContext, HandlerOptions. Domain code references this; the runtime piece (BaseHandler, HandlerContext, HandlerTelemetry, AddD2Handler) lives in DcsvIo.D2.Handler.
Install
dotnet add package DcsvIo.D2.Handler.Abstractions
Public surface
public interface IHandler<in TInput, TOutput>
{
ValueTask<D2Result<TOutput?>> HandleAsync(
TInput input,
CancellationToken ct = default,
HandlerOptions? options = null);
}
public interface IHandlerContext
{
IRequestContext Request { get; }
ILogger Logger { get; }
}
public sealed record HandlerOptions
{
public bool LogInput { get; init; } = true;
public bool LogOutput { get; init; } = true;
public TimeSpan? SlowThreshold { get; init; } = TimeSpan.FromMilliseconds(100);
public TimeSpan? CriticalThreshold { get; init; } = TimeSpan.FromMilliseconds(500);
public ScopeRequirement? ScopeRequirement { get; init; }
}
/// <summary>Declares the per-handler scope requirement.</summary>
public sealed record ScopeRequirement(HandlerScopeMatch Match, IReadOnlySet<string> Scopes);
public enum HandlerScopeMatch { Any, All }
ScopeRequirement combines an explicit match mode with the scope set: Match is HandlerScopeMatch.Any (caller must hold at least one of the scopes) or HandlerScopeMatch.All (caller must hold every scope). null or an empty Scopes set disables the per-handler pre-check entirely (pipeline guard is { Scopes.Count: > 0 } skips). HandlerScopeMatch lives in this assembly — handlers never take a compile-time dependency on DcsvIo.D2.Auth.Abstractions (layer-hygiene invariant).
JWT signature / expiry / audience / fingerprint-binding validation are NOT per-handler. They're transport-level concerns handled by auth middleware (HTTP / gRPC / AMQP) BEFORE the handler runs. Per-handler scope requirements (
ScopeRequirement) ARE here because they vary by operation; audience / signature / etc. are per-service constants and putting them onHandlerOptionswould be a footgun. SeeHandlerOptionsremarks for the fuller rationale.
Why split from DcsvIo.D2.Handler?
Domain code (entities + value objects + domain services) shouldn't depend on Microsoft.Extensions.DependencyInjection, OpenTelemetry, or any infrastructure package. The split lets domain projects reference only this lib (and pick up IHandler for handler-shaped domain services); the concrete + DI extension live in the sibling package DcsvIo.D2.Handler.
Dependencies
DcsvIo.D2.Result—D2Result<T>return typeDcsvIo.D2.Context.Abstractions—IRequestContexton the contextMicrosoft.Extensions.Logging.Abstractions—ILoggeron the context
Related packages
DcsvIo.D2.Handler— concreteBaseHandler+HandlerContext+ DI extensionDcsvIo.D2.Handler.Repo— EF-flavored handler that maps PG/EF exceptions toD2Resultfailure codes
Recommended layout: per-op handler folders (Application/Handlers/{Commands,Queries}/<Op>/).
| 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. |
-
net10.0
- DcsvIo.D2.Context.Abstractions (>= 0.1.1)
- DcsvIo.D2.Result (>= 0.1.1)
- dotenv.net (>= 4.0.2)
- JetBrains.Annotations (>= 2025.2.4)
- Microsoft.EntityFrameworkCore (>= 10.0.7)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.7)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Caching.Memory (>= 10.0.7)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Logging (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- Microsoft.IdentityModel.Tokens (>= 8.16.0)
- NodaTime (>= 3.2.2)
- Npgsql (>= 10.0.2)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.1)
- Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime (>= 10.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DcsvIo.D2.Handler.Abstractions:
| Package | Downloads |
|---|---|
|
DcsvIo.D2.Handler
BaseHandler for D2 — the abstract base every handler inherits, providing scope pre-checks, OpenTelemetry activity and metrics, log scope, and a universal try/catch. |
|
|
DcsvIo.D2.Handler.Repo
EF-flavored BaseRepoHandler for D2 — converts database exceptions captured during execution into typed D2Result failures. |
GitHub repositories
This package is not used by any popular GitHub repositories.