JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com
MIT License
293 stars 49 forks source link

MediatR Behaviors support #131

Open pizycki opened 4 years ago

pizycki commented 4 years ago

Hi, is it possible to add MediatR Pipeline Behaviours with Function Monkey?

FM @ 0.37

pizycki commented 4 years ago

I've just found the use of ICustomDispatcher. https://github.com/JamesRandall/FunctionMonkeyVideoSeries/blob/master/Part5/ServerlessBlog/CrossCuttingConcerns/CustomDispatcher.cs

What I'm trying to achieve is provide trace logging for all my command handlers.

So implementing ICustomDispatcher would be the best option now, right? :)

BTW, this project is great 👍

mdg215199 commented 4 years ago

Planning to test that this weekend (if possible). Specifically, I'm wanting it for efcore and using mediatr pipeline begintransaction/committransaction. Will let you know when i test it. Overall, commanding is a decent command handler. The other two issues i found that I had issues (in comparison with mediatr) is templating, something like

public class CommandTemplate<TCommand, TResponse> : IRequest<TResponse> where TCommand : IRequest<TResponse>

Was having issues getting it to work with commanding. That said, I may have done something stupid. I iddn't spend a ton of time yet in testing it.

Oh, and last, this is really really minor... lot of files, I'll put both command, commandhandler, response all in one file... lot of times all within same class. Mainly, it's easy to support/debug them. Well, as long as it is only that, and calling the logic out of it somewhere else. That said, you can just make the parent class being the end of the namespace then just have the classes being in the file (without being a children class of the parent). This is more on the compiler though, and i dont think it needs fixed. Just somethign i'm used to doing, but again, namespace does same thing.

mdg215199 commented 4 years ago

@pizycki sorry for state above and for not follow through yet. been side tracked last week and half due to life being life at times. i'm hoping to test this sometime this week, but will do so soon and will let you know.