mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-23 12:47:56 +00:00
Refactoring: migrate translations to singleton
It was using maps in each context, which would be merged between contexts, then injected each time we needed a message to display. It had a limitation on complicated operator setups: historical information would be overriden by newer associations. (e.g, that IP was for node0 yesterday, now it's node1, so associations have been overwritten and incorrect) It also introduced complexity, such as forcing to define closures too many times, merging maps, it would be harder to debug, and every files were starting from empty translation maps. Moreover, iterating on maps is guaranteed to be random so it could create hard-to-debug output variations on complex cases. Now it is a singleton in translate package, still using maps but now it associates an array of "units" storing the timestamp with each piece of information. It is protected by rwmutex, because map are not threadsafe. (there's no parallel processing for now) No regressions, and it passes "operator_ambiguous_ips_list_all_no_color" where the old system failed. It nows also can be used as an easy to read source of information in itself
This commit is contained in:

committed by
Sveta Smirnova

parent
e56fc45a05
commit
2091c1a1f0