Skip to content

Consider using Action<InvocationContext> and removing IInvocationResult #1936

Closed

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,
    }
}
 

Activity

  1. changed the title [-]Consider using `Action<InvocationContext>` instead of an interface[/-] [+]Consider using `Action<InvocationContext>` and removing `IInvocationResult`[/+] on Nov 2, 2022
  2. added
    needs discussion
    on Nov 2, 2022
  3. added a commit that references this issue on Nov 4, 2022
    04a84c2
  4. self-assigned this
    on Nov 4, 2022
  5. added this to the 2.0 GA milestone on Nov 9, 2022
  6. added a commit that references this issue on Nov 11, 2022
    e2cdee3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-APIneeds discussion

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions