Skip to content

Consider using Action<InvocationContext> and removing IInvocationResult #1936

@jonsequitur

Description

@jonsequitur
    // Usual "classes over interfaces" comment.
    // Definitely do not make a public interface that the library doesn't already provide at least three different implementations of (non-public ones count), otherwise we don't have confidence in the shape.
    public interface IInvocationResult 
    {
        void Apply(InvocationContext context);
    }
 
        // Where does this cancellation token come from?
        public System.Threading.CancellationToken GetCancellationToken();
    }
 
    // Even with a renamed concept of "middleware", I'm not sure a delegate feels like the right thing.
    // And what should a middleware do with "next"?  (Was the return type of the delegate supposed to be Task?)
    // I'm afraid this whole thing needs a full redesign (or, preferably, to be cut).
    public delegate void InvocationMiddleware(InvocationContext context, Func<InvocationContext,Task> next);
    
    // You are aware that callers can pass any value between int.MinValue and int.MaxValue, inclusive, right?
    public enum MiddlewareOrder
    {
        Default = 0,
        ErrorReporting = 1000,
        ExceptionHandler = -2000,
        Configuration = -1000,
    }
}
 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions