We did not have time in the last call to discuss this:
There are use cases where we need to share state between a request and a response
microservice. Now we have already 2 cases, so I suggest to define a common method to
achieve this. The same approach could also be used to access the common config, e.g. if
you need to know the proxy configuration (such as a backend entityid) in a microservice.
A simple mechanism would be to use a module-level variable as singleton:
=====================
shared_state.py
state = {}
———
plugins/microservices/a.py
from shared_state import state # import executes only once
…
state[’a’] = 'foo'
———
plugins/microservices/b.py
from shared_state import state
whatever(state['a‘])
=====================
I thing that for just passing request status to response microservices and passing config
data around this should be good enough. There are several alternatives, like the Borg
pattern, which I find harder to read.
- Rainer