Skip to content
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

Merged
merged 14 commits into from
Feb 28, 2024
Merged

Common clickhouse client #106

merged 14 commits into from
Feb 28, 2024

Conversation

kirillgarbar
Copy link
Contributor

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.

Comment on lines 36 to 38
@classmethod
def get(cls, string):
return cls._map[string] if string in cls._map else ClickhousePort.AUTO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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)

Comment on lines 252 to 254
if port in self.ports:
return self.ports[port]
return 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")
Copy link
Contributor

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")
Copy link
Contributor

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

)


def execute_query_client(
Copy link
Contributor

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

)["data"]


def execute_query(
Copy link
Contributor

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 ?

@aalexfvk aalexfvk merged commit 986522e into yandex:main Feb 28, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants