openmicroservices.org icon indicating copy to clipboard operation
openmicroservices.org copied to clipboard

Immutable vs mutable

Open stevepeak opened this issue 7 years ago • 1 comments

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.

stevepeak avatar Aug 20 '18 06:08 stevepeak

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).

wilzbach avatar Jul 30 '19 16:07 wilzbach