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…
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…
Il giorno gio 11 lug 2019 alle ore 22:10 Rainer Hoerbe <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
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
--
------------------------------------------------------------------------------------------------------------------
Il banner è generato automaticamente dal servizio di posta elettronica
dell'Università della Calabria
<http://www.unical.it/5x1000>