openmicroservices.org
openmicroservices.org copied to clipboard
Immutable vs mutable
Service outputs should have an optional keyword that states if the data is mutable or immutable. The default should be immutable.
During static analysis there can be a check to make sure data is not changed.
Imho all output should be immutable as the data needs to be serialized and send over the wire. So the service needs to make a "immutable copy" of it anyhow during serialization. Now there's the interesting point that a service might return the same response when called again which in that case won't even require a service call.
tl;dr:
- service output is always immutable (for the user)
- service actions could be cachable by the engine (-> https://github.com/microservices/microservice.guide/issues/100)
Note sure whether it's worthwhile to introduce a special attribute cachable for actions that don't change as this would only affect a small amount of actions (ii.e. the ones that are truly static).