this question is of general nature. Suppose you have a lot of microservices calling some internal library. This library has a core function core_function(arg_1,arg_2,..)
In some cases the function should react a bit differently. So what would be a good practice?
Some ideas that I have:
- Add an argument to the function.
behavior_param
. Drawback: Many microservice should be refactored. The microservices are classes. So I would have to introduce a new parameter to each class (or at least a default parameter) and use it when calling the function (of course only to the microservices that need the modified behaviour) -
Add some global variable in the library like
behavior_param
maybe in the __init__ file. Drawback: I would have a global parameter and don't like that. -
Using environment variables. It's like the second solution. But somehow I like that idea better
What do you think? Hope the question is clear. I'm searching for the best and most natural approach to this in python.
Aucun commentaire:
Enregistrer un commentaire