< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: AsyncResponse.CallbackParam
Assembly: AsyncResponse.Abstractions
File(s): /home/runner/work/AsyncResponse/AsyncResponse/src/AsyncResponse.Abstractions/ReflectionCallDto.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 81
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ForValue(...)100%11100%
ForPlaceholder(...)100%11100%

File(s)

/home/runner/work/AsyncResponse/AsyncResponse/src/AsyncResponse.Abstractions/ReflectionCallDto.cs

#LineLine coverage
 1namespace AsyncResponse;
 2
 3/// <summary>
 4/// A serializable description of a method invocation: the target service interface, the method
 5/// name, and a set of parameters (literal values or runtime placeholders). Because it is plain
 6/// data, it can be persisted (recovery state in Redis) or transported (worker queues) and
 7/// resolved against the DI container later — including after a redeploy, by a different process.
 8/// <para>
 9/// <b>Contract warning:</b> the service interface full name and method name are persisted as
 10/// strings and resolved by reflection. Renaming a registered service method is a breaking change
 11/// for recovery state and in-flight worker jobs created before the rename.
 12/// </para>
 13/// </summary>
 14public sealed class ReflectionCallDto
 15{
 16    /// <summary>
 17    /// The full name of the service interface (including namespace) to resolve from the DI container.
 18    /// </summary>
 19    public required string ServiceInterfaceFullName { get; set; }
 20
 21    /// <summary>The name of the method to invoke on the target service.</summary>
 22    public required string MethodName { get; set; }
 23
 24    /// <summary>
 25    /// Parameters for the method invocation. Each <see cref="CallbackParam"/> may either hold a
 26    /// literal value or indicate a runtime placeholder to be replaced with the real payload,
 27    /// exception, or correlation id.
 28    /// </summary>
 29    public required CallbackParam[] Params { get; set; }
 30}
 31
 32/// <summary>
 33/// A <see cref="ReflectionCallDto"/> resolved for execution; its <see cref="Params"/> are real
 34/// CLR objects with all placeholders substituted.
 35/// </summary>
 36public sealed class ReflectionInvocationDto
 37{
 38    public required string ServiceInterfaceFullName { get; init; }
 39    public required string MethodName { get; init; }
 40    public required object?[] Params { get; init; }
 41}
 42
 43/// <summary>
 44/// Enumerates the runtime values that can be injected into a <see cref="CallbackParam"/>
 45/// when a lost-subscriber callback is invoked.
 46/// </summary>
 47public enum PlaceholderType
 48{
 49    /// <summary>Replaced by the response payload.</summary>
 50    Payload,
 51
 52    /// <summary>Replaced by the exception instance (technical or domain failure).</summary>
 53    Exception,
 54
 55    /// <summary>Replaced by the correlation id string.</summary>
 56    CorrelationId,
 57}
 58
 59/// <summary>
 60/// Describes a single invocation parameter for a <see cref="ReflectionCallDto"/>:
 61/// either a literal <see cref="Value"/>, or a <see cref="Placeholder"/> token resolved at runtime.
 62/// </summary>
 63public sealed class CallbackParam
 64{
 65    /// <summary>
 66    /// If non-null, indicates which runtime value (payload, exception, or correlation id)
 67    /// should be injected instead of <see cref="Value"/>.
 68    /// </summary>
 69    public PlaceholderType? Placeholder { get; set; }
 70
 71    /// <summary>The literal value to pass when <see cref="Placeholder"/> is <c>null</c>.</summary>
 72    public object? Value { get; set; }
 73
 74    /// <summary>Creates a <see cref="CallbackParam"/> holding the given literal value.</summary>
 75    public static CallbackParam ForValue(object? value)
 376        => new() { Placeholder = null, Value = value };
 77
 78    /// <summary>Creates a <see cref="CallbackParam"/> resolved at runtime to the given placeholder.</summary>
 79    public static CallbackParam ForPlaceholder(PlaceholderType placeholder)
 380        => new() { Placeholder = placeholder, Value = null };
 81}