As Scott pointed out in a separate mail it will not work between request and response
microservices, however. Actually I did implement a cookie-based state sharing, but that
was before I went on vacation for 3 weeks :-)
I still love the simplicity of getting configurations with a simple import like with
django, but it is not that important for this project.
Cheers, Rainer
Am 2019-07-11 um 23:19 schrieb Giuseppe De Marco
<giuseppe.demarco at unical.it>:
Hi Rainer,
very interesting to me.
The last time I heard Borg pattern was 2010, I'm touched.
It's simply a singleton pattern variation based on an attributes stored in the class
scope.
With your example I understand your proposal and yes, I think that's a good solution
to handle this kind of shared state.
In the past I used a modified singleton to share objects built with the same arguments:
https://github.com/faif/python-patterns/blob/master/patterns/creational/bor…
<https://github.com/faif/python-patterns/blob/master/patterns/creational/borg.py>
this is also a simpler pure-borg example that I found very fun in its simplicity
https://github.com/faif/python-patterns/blob/master/patterns/creational/bor…
<https://github.com/faif/python-patterns/blob/master/patterns/creational/borg.py>
Il giorno gio 11 lug 2019 alle ore 22:10 Rainer Hoerbe <rainer at hoerbe.at
<mailto:rainer at hoerbe.at>> ha scritto:
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
_______________________________________________
Satosa-dev mailing list
Satosa-dev at lists.sunet.se <mailto:Satosa-dev at lists.sunet.se>
https://lists.sunet.se/listinfo/satosa-dev
<https://lists.sunet.se/listinfo/satosa-dev>
--
____________________
Dott. Giuseppe De Marco
CENTRO ICT DI ATENEO
University of Calabria
87036 Rende (CS) - Italy
Phone: +39 0984 496961
e-mail: giuseppe.demarco at unical.it <mailto:giuseppe.demarco at unical.it>
------------------------------------------------------------------------------------------------------------------
Il banner è generato automaticamente dal servizio di posta elettronica
dell'Università della Calabria
<http://www.unical.it/5x1000>