-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
External Mapping Storage #1068
Comments
So instead of storing the Mappings in memory, you want to store the mappings in CosmosDB? |
Exactly :) We deploy a Wiremock server for a large suite of integration tests so it would great to be able to scale up the server instances as we dynamically add scenarios for specific tests. |
In that case, some ideas for the approach...
|
Awesome, thanks for the pointers. Will keep you posted. |
Can't move IMappingProvider to abstractions. It has a dependency on IMapping which itself has a dependency on a whole bunch of stuff in the Wiremock.net project. |
Good point. In that case keep it in the main project. |
Hmmm looking more and more like this won't be suitable for everyone; The Azure Cosmos SDK doesn't support 4.5.2 so I'll need to drop support for that. |
That is not issue if The same is for GraphQL and gRPC, that is only available for the newer frameworks. |
Unfortunately due to the dependencies of IMapping, we can't have an external project reference the WireMock.net project for the Interface and then the Wiremock.net project reference a Cosmos project. It causes a circular dependency. Implementing this is very low level, not really plugin. I think this is a fork forever... |
It is possible, The interface Loading the type is done here:
(Maybe PluginLoader is a wrong name, maybe better like TypeLoader or something...) |
@StefH Ahhhhh ok, I'm starting to understand how you've done it now. Okay, I'll keep persevering 👍🏼 |
Ok. Good to hear. In case you would like to build this logic and need an updated WireMock.Net, please tell me. Then I'll merge . Also think on the naming: So maybe:
or
Are better names? |
Your new code will be essential so please go ahead. With regards to the name, TypeLoader has clearer intentions. Thank you for your help with this, it is greatly appreciated. |
@PG-RichT |
Would you like to create a PR for your new code? Then I can already add comments on the code while you develop? |
@StefH Will do as soon I've resolved my current blocker - serializing the Interfaces used throughout a Mapping object in order to store them in the database. |
Yes, serializing the What you could try is use the MappingConverter to convert a IMapping <> MappingModel (this is the same is used on the HTTP admin interface). However, you will lose some functionality like the Func<> callbacks. |
@PG-RichT What you actually can do is just implement the This interface is used to read and write all the files needed by WireMock.Net , this also includes the mapping (MappingModel -JSON) files. |
@StefH Thanks for that. I have started an approach (I don't know if it will work yet) that recognises an internal mapping i.e. one used by wiremock only, versus a user mapping. Internal mappings will be stored in a concurrent dictionary like before, user mappings in cosmos. I don't know how this will affect performance or if it will even work yet but let's see... |
There is technically no difference between a wiremock internal or a user mapping. These are all Mappings. So I think the best approach is : saving/reading the MappingModels as JSON in the CosmosDB using the IFileSystemHandler . |
@StefH Apologies for a delay in my response. I have been assessing the implementation using the IFileSystemHandler and unfortunately I don't think it meets the requirements I would want out of backend storage. Ideally the database of mappings would be called per request so any number of Wiremock instances could be spun up. If we go down the IFileSystemHandler route we introduce potential latency as each instance responds to an event telling it that 'the database has been updated, go refresh your in-memory mappings'. That latency might be tiny but the fact that it exists is enough to put me off. Instead I have been looking at other infrastructure approaches to achieve our end-goal, sticky sessions appears to be simplest. I wanted to thank you for your help so I could come to this conclusion though and for all the hard work and effort you put into maintaining this repo. Thank you. |
Hi there,
Are there any plans to support an external source for the Mappings data?
I ask because I've started an exploratory feature branch to support Cosmos DB and a colleague suggested getting in touch in case this is on your roadmap? If not, do you have any suggestions or requirements that could ease the merging of this code into your master repo at some point?
Here's my very quick stab at how it could be done: https://github.com/WireMock-Net/WireMock.Net/compare/master...PG-RichT:WireMock.Net:cosmos_backend?expand=1
Thanks,
Rich
The text was updated successfully, but these errors were encountered: