mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-12 02:23:14 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
57 lines
2.1 KiB
C++
57 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <Core/Types.h>
|
|
#include <Core/UUID.h>
|
|
#include <Common/SettingsChanges.h>
|
|
#include <Access/SettingsConstraints.h>
|
|
#include <Access/SettingsProfileElement.h>
|
|
#include <mutex>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
/// Watches settings profiles for a specific user and roles.
|
|
class EnabledSettings
|
|
{
|
|
public:
|
|
struct Params
|
|
{
|
|
UUID user_id;
|
|
std::vector<UUID> enabled_roles;
|
|
SettingsProfileElements settings_from_enabled_roles;
|
|
SettingsProfileElements settings_from_user;
|
|
|
|
auto toTuple() const { return std::tie(user_id, enabled_roles, settings_from_enabled_roles, settings_from_user); }
|
|
friend bool operator ==(const Params & lhs, const Params & rhs) { return lhs.toTuple() == rhs.toTuple(); }
|
|
friend bool operator !=(const Params & lhs, const Params & rhs) { return !(lhs == rhs); }
|
|
friend bool operator <(const Params & lhs, const Params & rhs) { return lhs.toTuple() < rhs.toTuple(); }
|
|
friend bool operator >(const Params & lhs, const Params & rhs) { return rhs < lhs; }
|
|
friend bool operator <=(const Params & lhs, const Params & rhs) { return !(rhs < lhs); }
|
|
friend bool operator >=(const Params & lhs, const Params & rhs) { return !(lhs < rhs); }
|
|
};
|
|
|
|
~EnabledSettings();
|
|
|
|
/// Returns the default settings come from settings profiles defined for the user
|
|
/// and the roles passed in the constructor.
|
|
std::shared_ptr<const Settings> getSettings() const;
|
|
|
|
/// Returns the constraints come from settings profiles defined for the user
|
|
/// and the roles passed in the constructor.
|
|
std::shared_ptr<const SettingsConstraints> getConstraints() const;
|
|
|
|
private:
|
|
friend class SettingsProfilesCache;
|
|
EnabledSettings(const Params & params_);
|
|
|
|
void setSettingsAndConstraints(
|
|
const std::shared_ptr<const Settings> & settings_, const std::shared_ptr<const SettingsConstraints> & constraints_);
|
|
|
|
const Params params;
|
|
SettingsProfileElements settings_from_enabled;
|
|
std::shared_ptr<const Settings> settings;
|
|
std::shared_ptr<const SettingsConstraints> constraints;
|
|
mutable std::mutex mutex;
|
|
};
|
|
}
|