Plugin copy and caching- part 14
I have had 2 problems to solve
- How to put the plugins for the console and web api ?
- How to cache the data ? ( plugins / exchange rates)
The solution for the first problem should be easy for the programmer PC, and for the deploying the application ( console/ web api/ etc )There are several solutions :
- Each plugin knows where to copy the dll ( console/web api)
- The application ( console / webapi) knows a special place from which to copy the plugin definition
I tend to agree with both – but mostly with the second. So … the idea is as follows:
The plugin builds and copy the output to a special folder, named “plugins” ( what a surprise, righyt?)
The console /webapi copies the folder plugins under his directory
The only problem here is that we should ensure that plugins are build first, even if the application does NOT have reference to them.
For this, there is a special menu in VS for solution, namely “build order” – you go to this –and after to the second tab, project dependencies. For the console and web I select as dependency the two loading projects – InfoValutarNBR and InfoValutarECB. The changes are reflected into the sln file
I could have done this on just the InfoValutarLoadingLibs project – but maybe I can have another way to load the libraries ( not so much for the moment )
So now I begin to modify what happens
after build events for InfoValutarNBR and InfoValutarECB
xcopy “$(TargetDir)*.*” “$(SolutionDir)plugins\$(ProjectName)” /E /F /I /Y /R
and pre build events for InfoValutarDOS and InfoValutarWebAPI.
Now, there are several things to do:
- Add to .gitignore the plugins folder to not put into the source control( ok)
- Write some documentation about the process
- Think about linux/docker compiling – there is a xcopy there ?
About the documentation – I just did. More, I create a InfoValutarPluginStarter , in order for others to copy this project and make a new plugin.
Realized also that the WebAPI could be simpler
[HttpGet(“{bank}”)]
public IAsyncEnumerable<ExchangeRates> Rates([FromRoute] string bank)
And also that I should throw another exception if Bank is null or empty:
if(string.IsNullOrWhiteSpace(bank))
throw new ArgumentNullException($”{nameof(bank)} cannot be empty”);
For docker compiling – next time
Infovalutar
And one hour passes...(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )
Leave a Reply