ml-tooling / contaxy

MIT License
10 stars 8 forks source link

Refactor managers to use the ComponentManager to access other managers #45

Closed JNKielmann closed 2 years ago

JNKielmann commented 2 years ago

The different managers in contaxy (e.g. SystemManager, AuthManager, etc.) need access to other managers. So far, these dependent managers were passed via the constructor directly. However, for some of the managers a cyclic dependency can arise. For example the ServiceManager needs the AuthManager to generate self access tokens for newly created services. But at the same time, the AuthManager should use the ServiceManager to update the "last accessed" timestamp of a service when a new session token for that service is generated. To allow this kind of dependency, instead of passing the AuthManager directly to the ServiceManager, instead, the ComponentManager is passed which can be used to retrieve the AuthManager. In the constructor of the ServiceManager, the get_auth_manager() function must not be called directly (as this would lead to a dependency loop again). Instead, a property for each required manager is defined, that calls the respective getter method of the ComponentManager. This also improves the lazy loading of the managers, as the getter function is only called, if the manager is actually required.

This change also required to use the "operations" abstract base classes in all signatures instead of the concrete "manager" classes (e.g. SystemOperations instead of SystemManager). Some methods were only implemented in the manager classes and not in the respective abstract base class. These missing functions were added, but the corresponding implementation in the client classes where left black for now.