#pragma once #include #include #include #include #include namespace DB { class AccessControlManager; struct Role; using RolePtr = std::shared_ptr; class RoleCache { public: RoleCache(const AccessControlManager & manager_); ~RoleCache(); std::shared_ptr getEnabledRoles( const std::vector & current_roles, const std::vector & current_roles_with_admin_option); private: void collectEnabledRoles(scope_guard & notifications); void collectEnabledRoles(EnabledRoles & enabled, scope_guard & notifications); RolePtr getRole(const UUID & role_id); void roleChanged(const UUID & role_id, const RolePtr & changed_role); void roleRemoved(const UUID & role_id); const AccessControlManager & manager; Poco::ExpireCache> cache; std::map> enabled_roles; mutable std::mutex mutex; }; }