I'm looking for a Design Pattern for updating a server object from multiple sources.
Current Situation:
- There is a mobile app which shows and modifies data.
- There is server which stores data with a object version
- There is a new services which also updates some properties of the data object on the server
The object version property is increased every time the object is changed on the server. The mobile application has to send the current version with the new data, to not change a newer version of the object on the server. In that case an error is thrown.
So this is fine, as long there is only an app-server relationship and the app ensures, that it updates its local object in case there is a newer one on the server.
New requirement:
There is a new service which updates the object on the server (maybe) simultaneously with the mobile application. So an external source sends new data to the server which updates the object and increases the version.
Then it can happen, that the mobile application also sends new object data and now the question is, whats newer and how to ensure to not overwrite "newer" property values.
The new service will not update all properties from the object, only selected ones, but these properties can also be changed by the mobile application.
My idea:
I could create an additional version property which indicates the version of the objects properties which can be changed by mobile app and external service. So this way, the mobile application would send both versions in an update. Then the object version indicates which properties are used to update from the mobile app and the second version will handle the other properties which may be changed in the meantime from the other source. If server object version2 value is equal the mobile apps values are stored. if not, they will be discarded, because somebody has changed these values in the meantime.
Question
Does anybody see drawbacks in this solution or are there existing design patterns for such object versioning?
Aucun commentaire:
Enregistrer un commentaire