mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Use standard markup '{}' like macros. Add coments.
This commit is contained in:
parent
27a9ce8dd7
commit
052079b73a
@ -381,7 +381,7 @@ private:
|
||||
Strings keys;
|
||||
config().keys("prompt_by_server_display_name", keys);
|
||||
|
||||
prompt_by_server_display_name = config().getString("prompt_by_server_display_name.default", "%display_name% :)");
|
||||
prompt_by_server_display_name = config().getString("prompt_by_server_display_name.default", "{display_name} :) ");
|
||||
|
||||
for (const String & key : keys)
|
||||
{
|
||||
@ -514,11 +514,8 @@ private:
|
||||
{
|
||||
String pattern = prompt_by_server_display_name;
|
||||
|
||||
for (const auto & [key, value]: colors)
|
||||
for (const auto & [name, code]: colors)
|
||||
{
|
||||
String name = static_cast<String>(key);
|
||||
String code = static_cast<String>(value);
|
||||
|
||||
boost::replace_all(pattern, "[" + name + "]", "\33[1;" + code + "m");
|
||||
boost::replace_all(pattern, "[/" + name + "]", "\033[0m");
|
||||
}
|
||||
@ -533,7 +530,7 @@ private:
|
||||
|
||||
for (const auto & [key, value]: environment)
|
||||
{
|
||||
boost::replace_all(pattern, "%" + static_cast<String>(key) + "%", static_cast<String>(value));
|
||||
boost::replace_all(pattern, "{" + key + "}", value);
|
||||
}
|
||||
|
||||
return pattern;
|
||||
|
@ -198,7 +198,7 @@ HTTPHandler::HTTPHandler(IServer & server_)
|
||||
: server(server_)
|
||||
, log(&Logger::get("HTTPHandler"))
|
||||
{
|
||||
display_name = server.config().getString("display_name", getFQDNOrHostName());
|
||||
server_display_name = server.config().getString("display_name", getFQDNOrHostName());
|
||||
}
|
||||
|
||||
|
||||
@ -632,7 +632,7 @@ void HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest & request, Poco::Ne
|
||||
try
|
||||
{
|
||||
response.setContentType("text/plain; charset=UTF-8");
|
||||
response.set("X-ClickHouse-Display-Name", display_name);
|
||||
response.set("X-ClickHouse-Server-Display-Name", server_display_name);
|
||||
/// For keep-alive to work.
|
||||
if (request.getVersion() == Poco::Net::HTTPServerRequest::HTTP_1_1)
|
||||
response.setChunkedTransferEncoding(true);
|
||||
|
@ -54,7 +54,9 @@ private:
|
||||
|
||||
IServer & server;
|
||||
Poco::Logger * log;
|
||||
String display_name;
|
||||
|
||||
/// It is the name of the server that will be sent in an http-header X-ClickHouse-Server-Display-Name.
|
||||
String server_display_name;
|
||||
|
||||
CurrentMetrics::Increment metric_increment{CurrentMetrics::HTTPConnection};
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "TCPHandler.h"
|
||||
|
||||
#include <Common/NetException.h>
|
||||
#include <Common/getFQDNOrHostName.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -511,7 +510,7 @@ void TCPHandler::sendHello()
|
||||
}
|
||||
if (client_revision >= DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME)
|
||||
{
|
||||
writeStringBinary(server.config().getString("display_name", getFQDNOrHostName()), *out);
|
||||
writeStringBinary(server_display_name, *out);
|
||||
}
|
||||
out->next();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <Poco/Net/TCPServerConnection.h>
|
||||
|
||||
#include <Common/getFQDNOrHostName.h>
|
||||
#include <Common/CurrentMetrics.h>
|
||||
#include <Common/Stopwatch.h>
|
||||
#include <IO/Progress.h>
|
||||
@ -81,6 +82,7 @@ public:
|
||||
, connection_context(server.context())
|
||||
, query_context(server.context())
|
||||
{
|
||||
server_display_name = server.config().getString("display_name", getFQDNOrHostName());
|
||||
}
|
||||
|
||||
void run();
|
||||
@ -111,7 +113,9 @@ private:
|
||||
QueryState state;
|
||||
|
||||
CurrentMetrics::Increment metric_increment{CurrentMetrics::TCPConnection};
|
||||
|
||||
|
||||
/// It is the name of the server that will be sent to the client.
|
||||
String server_display_name;
|
||||
|
||||
void runImpl();
|
||||
|
||||
|
@ -13,9 +13,18 @@
|
||||
</invalidCertificateHandler>
|
||||
</client>
|
||||
</openSSL>
|
||||
<!--
|
||||
It's a custom prompt settings for the clickhouse-client
|
||||
Possible macros:
|
||||
{host}
|
||||
{port}
|
||||
{user}
|
||||
{database}
|
||||
{display_name}
|
||||
-->
|
||||
<prompt_by_server_display_name>
|
||||
<default>%display_name% :)</default>
|
||||
<test>%display_name% [green]:)[/green]</test>
|
||||
<production>%display_name% [red]:)[/red]</production>
|
||||
<default>{display_name} :) </default>
|
||||
<test>{display_name} [green]:)[/green </test> <!-- if it matched to the substring "test" in the server display name - -->
|
||||
<production>{display_name} [red]:)[/red] </production> <!-- if it matched to the substring "production" in the server display name -->
|
||||
</prompt_by_server_display_name>
|
||||
</config>
|
||||
|
Loading…
Reference in New Issue
Block a user