-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common clickhouse client #106
Conversation
@classmethod | ||
def get(cls, string): | ||
return cls._map[string] if string in cls._map else ClickhousePort.AUTO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@classmethod | |
def get(cls, string): | |
return cls._map[string] if string in cls._map else ClickhousePort.AUTO | |
@classmethod | |
def get(cls, port: str, default: ClickhousePort = ClickhousePort.AUTO) -> ClickhousePort: | |
return cls._map.get(port, default) |
if port in self.ports: | ||
return self.ports[port] | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if port in self.ports: | |
return self.ports[port] | |
return 0 | |
return self.ports.get(port, 0) |
def get_ports(): | ||
ports: Dict[ClickhousePort, str] = {} | ||
try: | ||
root = xml.parse("/var/lib/clickhouse/preprocessed_configs/config.xml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use
CLICKHOUSE_SERVER_PREPROCESSED_CONFIG_PATH = ( |
ports[ClickhousePortHelper.get(setting)] = str(node.text) | ||
if not ports: | ||
raise UserWarning(2, "Can't find any port in clickhouse-server config") | ||
node = root.find("./openSSL/server/caConfig") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string constants we can also move to path.py
ch_tools/monrun_checks/utils.py
Outdated
) | ||
|
||
|
||
def execute_query_client( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this function to ClickhouseClient
as member function query_json_data()
We can use it also in replication_lag.py
ch_tools/monrun_checks/utils.py
Outdated
)["data"] | ||
|
||
|
||
def execute_query( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What benefit of this proxy function ? Could we use clickhouse_client()
instead ?
Clickhouse clients in tests and monitoring replaced with common client and wrappers around it.
Port resolution code with http and tcp execution methods is moved to common client.