Distribt icon indicating copy to clipboard operation
Distribt copied to clipboard

Create shared.awaiter

Open ElectNewt opened this issue 3 years ago • 5 comments

in some scenarios (mainly config) we are executing async communication in non-async flows. for that reason instead of doing just .Result i should write a wrapper around it like Awaiter.Execute or something like that that executes that piece of code.

ElectNewt avatar Feb 07 '22 20:02 ElectNewt

I was searching the places this situation happens. I found that only appear on dependency injection situations Look all the .Result places: image

There are many places to touch but I think it can be possible using async and await sentences. For example I tried with SecretManager class:

  • in the class: image
  • In the web application creation (there are many but this is an example): image
  • and the Program.cs image

In this way al process are asynchronous but there is necessary change many files (I can do it if you want and you are agree)

AlexScigalszky avatar Dec 01 '22 21:12 AlexScigalszky

@AlexScigalszky yep it is for the DI I will need to think if there is any implication on converting sync scenarios in async but I dont think so. It's a better solution that the wrapper around the result, that's for sure 😂

Yo can do it if you are bored or you want to contribute :D, otherwise i will do it probably during the wekend. At the end of the day, the code is not being used in production (at least by me) so there is no rush. haha.

ElectNewt avatar Dec 01 '22 23:12 ElectNewt

@ElectNewt I already did a big part of this changes (just to be sure my idea is good). Now I finish all changes that you can see in this PR (please don't merge it yet): https://github.com/ElectNewt/Distribt/pull/35

I tried to run but I got this error, can you help me? image

AlexScigalszky avatar Dec 02 '22 19:12 AlexScigalszky

🤔 thats sounds familiar. I think that is the reason why I was thinking in the shared awaiter library

ElectNewt avatar Dec 04 '22 13:12 ElectNewt

It took a long time but finally, I did it!

I create an async version of DefaultDistribtWebApplication.Create() method

Please, feel free to review and comment on any improvement in the PR: https://github.com/ElectNewt/Distribt/pull/35

AlexScigalszky avatar Jan 31 '24 23:01 AlexScigalszky