-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Middleware for Handlers #809
Implement Middleware for Handlers #809
Conversation
Codecov Report
@@ Coverage Diff @@
## master #809 +/- ##
==========================================
- Coverage 81.45% 81.39% -0.06%
==========================================
Files 109 113 +4
Lines 2804 2838 +34
==========================================
+ Hits 2284 2310 +26
- Misses 520 528 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
src/JustSaying/Messaging/Middleware/Handle/HandlerInvocationMiddleware.cs
Outdated
Show resolved
Hide resolved
@martincostello can we target this for post-beta? I'm really keen to get the beta process rolling so we can get some features using the new backend. |
src/JustSaying/AwsTools/MessageHandling/Dispatch/MiddlewareMap.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/ExactlyOnce/ExactlyOnceMiddleware.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Handle/DelegateHandleMiddleware.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Handle/HandleMessageContext.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
We can have as many alpha/beta/gamma/whatevers as we want before release internally, and we have the ProGet feed we can host packages in, so I don't think it really matters what label we give it or whatever the release cadence is (or the need to be super-strict on SemVer). I'd only worry about these distinctions for putting something in NuGet.org, and I think we'd want to be fairly confidently "done" and happy it's working before publishing a beta there. |
That makes perfect sense, thanks 👍. The main reason for a beta was so that we can switch to a package feed instead of local packages, so as you say we can just use proget 🙂. |
src/JustSaying/AwsTools/MessageHandling/Dispatch/MessageDispatcher.cs
Outdated
Show resolved
Hide resolved
…g the generic handler
- Most of the way there, just some tests to go - Consumer API still needs a little TLC
…ndlers that enables extensibility around handlers, replaces HandlerMap - Reimplements ExactlyOnce as middleware instead of a wrapped handler - Adds configuration API that enables MVC-like configuration of the handler pipeline - Lower log level of multiplexer subscriber so its less noisy on startup when running with debug logs - Instead of passing the next middleware via ctor, do it via WithNext on MiddlewareBase so that we can pull middlewares from DI
- Add new line to make middleware clear
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
…er.cs Co-authored-by: Martin Costello <martin@martincostello.com>
…dleware.cs Co-authored-by: Martin Costello <martin@martincostello.com>
…dleware.cs Co-authored-by: Martin Costello <martin@martincostello.com>
…dleware.cs Co-authored-by: Martin Costello <martin@martincostello.com>
…eware.cs Co-authored-by: Martin Costello <martin@martincostello.com>
…ilderExtensions.cs Co-authored-by: Martin Costello <martin@martincostello.com>
- Rename resolver to handlerResolver to clearly differentiate between the two
…ilderExtensions.cs Co-authored-by: Martin Costello <martin@martincostello.com>
- Update tests to use ExactlyOnce middleware - Lots of docs for middleware extensions - Split middleware extension methods into folders
- Make middleware map return constructed middleware instead of a func
This is now ready for review! I've documented the public interfaces, added tests, and removed the old exactly-once and stopwatch handlers and reimplemented as middlewares. |
tests/JustSaying.TestingFramework/JustSaying.TestingFramework.csproj
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments, overall a really good addition 😃
src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilder.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Metrics/StopwatchMiddleware.cs
Outdated
Show resolved
Hide resolved
tests/JustSaying.TestingFramework/JustSaying.TestingFramework.csproj
Outdated
Show resolved
Hide resolved
- Push Shouldly back up to 4 now that the type load exception is fixed - Fix some docs
src/JustSaying/Messaging/Middleware/ExactlyOnce/ExactlyOnceMiddleware.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Handle/HandlerMiddlewareBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/JustSaying/Messaging/Middleware/Metrics/HandlerMiddlewareBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
- Rename some variables for clarity
…ace for visibility. - Fix up some formatting/spacing - Add some arg checks
…ilderExtensions.cs Co-authored-by: Martin Costello <martin@martincostello.com>
...JustSaying/Messaging/Middleware/ExactlyOnce/ExactlyOnceHandlerMiddlewareBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
…dlerMiddlewareBuilderExtensions.cs Co-authored-by: Martin Costello <martin@martincostello.com>
This PR implements a middleware layer around handlers. Middlewares have a number of advantages over existing solutions:
IHandlerAsync<T>
CancellationToken
, whereasIHandlerAsync<T>
cannot change to add one (or at least we haven't decided to do that)This work is largely based on the existing middleware code added by @maisiesadler that is used in the
MessageReceiveBuffer
's receive pipeline.Some example code
Middlewares can be pulled from DI, or passed in explicitly:
Produces:
Implementation of an extension method that makes a
UseExactlyOnce
method available to the pipeline, and resolves some services from DIUsage of
UseExactlyOnce
They can be chained: