Skip to content

Commit

Permalink
Add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Sep 2, 2024
1 parent 3f48362 commit 2f7f8bd
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 15 deletions.
4 changes: 2 additions & 2 deletions clickhouse-admin/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl ClickhouseAdminApi for ClickhouseAdminImpl {
let ctx = rqctx.context();
let server_settings = body.into_inner();
let output = ctx.clickward().generate_server_config(server_settings)?;
// TODO: Do something with the generation number
// TODO(https://github.com/oxidecomputer/omicron/issues/5999): Do something with the generation number
println!("{path:?}");
Ok(HttpResponseCreated(output))
}
Expand All @@ -44,7 +44,7 @@ impl ClickhouseAdminApi for ClickhouseAdminImpl {
let ctx = rqctx.context();
let keeper_settings = body.into_inner();
let output = ctx.clickward().generate_keeper_config(keeper_settings)?;
// TODO: Do something with the generation number
// TODO(https://github.com/oxidecomputer/omicron/issues/5999): Do something with the generation number
println!("{path:?}");
Ok(HttpResponseCreated(output))
}
Expand Down
18 changes: 18 additions & 0 deletions clickhouse-admin/types/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,24 @@ pub fn path_schema(gen: &mut SchemaGenerator) -> Schema {
/// Configuration for a ClickHouse replica server
#[derive(Debug, Clone, PartialEq, Eq, JsonSchema, Serialize, Deserialize)]
pub struct ReplicaConfig {
/// Logging settings
pub logger: LogConfig,
/// Parameter substitutions for replicated tables
pub macros: Macros,
/// Address the server is listening on
pub listen_host: Ipv6Addr,
/// Port for HTTP connections
pub http_port: u16,
/// Port for TCP connections
pub tcp_port: u16,
/// Port for interserver HTTP connections
pub interserver_http_port: u16,
/// Configuration of clusters used by the Distributed table engine and bythe cluster
/// table function
pub remote_servers: RemoteServers,
/// Contains settings that allow ClickHouse servers to interact with a Keeper cluster
pub keepers: KeeperConfigsForReplica,
/// Directory for all files generated by ClickHouse itself
#[schemars(schema_with = "path_schema")]
pub data_path: Utf8PathBuf,
}
Expand Down Expand Up @@ -444,15 +454,23 @@ impl RaftServerConfig {
/// Configuration for a ClickHouse keeper
#[derive(Debug, Clone, PartialEq, Eq, JsonSchema, Serialize, Deserialize)]
pub struct KeeperConfig {
/// Logging settings
pub logger: LogConfig,
/// Address the keeper is listening on
pub listen_host: Ipv6Addr,
/// Port for TCP connections
pub tcp_port: u16,
/// Unique ID for this keeper node
pub server_id: KeeperId,
/// Directory for coordination logs
#[schemars(schema_with = "path_schema")]
pub log_storage_path: Utf8PathBuf,
/// Directory for coordination snapshot storage
#[schemars(schema_with = "path_schema")]
pub snapshot_storage_path: Utf8PathBuf,
/// Internal coordination settings
pub coordination_settings: KeeperCoordinationSettings,
/// Settings for each server in the keeper cluster
pub raft_config: RaftServers,
}

Expand Down
11 changes: 11 additions & 0 deletions clickhouse-admin/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,19 @@ pub struct ServerId(pub u64);
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct ServerSettings {
/// Directory for the generated server configuration XML file
#[schemars(schema_with = "path_schema")]
pub config_dir: Utf8PathBuf,
/// Unique ID of the server
pub node_id: ServerId,
/// Directory for all files generated by ClickHouse itself
#[schemars(schema_with = "path_schema")]
pub datastore_path: Utf8PathBuf,
/// Address the server is listening on
pub listen_addr: Ipv6Addr,
/// Addresses for each of the individual nodes in the Keeper cluster
pub keepers: Vec<ClickhouseHost>,
/// Addresses for each of the individual replica servers
pub remote_servers: Vec<ClickhouseHost>,
}

Expand Down Expand Up @@ -127,12 +133,17 @@ impl ServerSettings {
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct KeeperSettings {
/// Directory for the generated keeper configuration XML file
#[schemars(schema_with = "path_schema")]
pub config_dir: Utf8PathBuf,
/// Unique ID of the keeper
pub node_id: KeeperId,
/// ID and host of each server in the keeper cluster
pub raft_servers: Vec<RaftServerSettings>,
/// Directory for all files generated by ClickHouse itself
#[schemars(schema_with = "path_schema")]
pub datastore_path: Utf8PathBuf,
/// Address the keeper is listening on
pub listen_addr: Ipv6Addr,
}

Expand Down
94 changes: 81 additions & 13 deletions openapi/clickhouse-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,30 +171,54 @@
"type": "object",
"properties": {
"coordination_settings": {
"$ref": "#/components/schemas/KeeperCoordinationSettings"
"description": "Internal coordination settings",
"allOf": [
{
"$ref": "#/components/schemas/KeeperCoordinationSettings"
}
]
},
"listen_host": {
"description": "Address the keeper is listening on",
"type": "string",
"format": "ipv6"
},
"log_storage_path": {
"description": "Directory for coordination logs",
"type": "string",
"format": "Utf8PathBuf"
},
"logger": {
"$ref": "#/components/schemas/LogConfig"
"description": "Logging settings",
"allOf": [
{
"$ref": "#/components/schemas/LogConfig"
}
]
},
"raft_config": {
"$ref": "#/components/schemas/RaftServers"
"description": "Settings for each server in the keeper cluster",
"allOf": [
{
"$ref": "#/components/schemas/RaftServers"
}
]
},
"server_id": {
"$ref": "#/components/schemas/KeeperId"
"description": "Unique ID for this keeper node",
"allOf": [
{
"$ref": "#/components/schemas/KeeperId"
}
]
},
"snapshot_storage_path": {
"description": "Directory for coordination snapshot storage",
"type": "string",
"format": "Utf8PathBuf"
},
"tcp_port": {
"description": "Port for TCP connections",
"type": "integer",
"format": "uint16",
"minimum": 0
Expand Down Expand Up @@ -275,21 +299,30 @@
"type": "object",
"properties": {
"config_dir": {
"description": "Directory for the generated keeper configuration XML file",
"type": "string",
"format": "Utf8PathBuf"
},
"datastore_path": {
"description": "Directory for all files generated by ClickHouse itself",
"type": "string",
"format": "Utf8PathBuf"
},
"id": {
"$ref": "#/components/schemas/KeeperId"
},
"listen_addr": {
"description": "Address the keeper is listening on",
"type": "string",
"format": "ipv6"
},
"node_id": {
"description": "Unique ID of the keeper",
"allOf": [
{
"$ref": "#/components/schemas/KeeperId"
}
]
},
"raft_servers": {
"description": "ID and host of each server in the keeper cluster",
"type": "array",
"items": {
"$ref": "#/components/schemas/RaftServerSettings"
Expand All @@ -299,8 +332,8 @@
"required": [
"config_dir",
"datastore_path",
"id",
"listen_addr",
"node_id",
"raft_servers"
]
},
Expand Down Expand Up @@ -442,36 +475,61 @@
"type": "object",
"properties": {
"data_path": {
"description": "Directory for all files generated by ClickHouse itself",
"type": "string",
"format": "Utf8PathBuf"
},
"http_port": {
"description": "Port for HTTP connections",
"type": "integer",
"format": "uint16",
"minimum": 0
},
"interserver_http_port": {
"description": "Port for interserver HTTP connections",
"type": "integer",
"format": "uint16",
"minimum": 0
},
"keepers": {
"$ref": "#/components/schemas/KeeperConfigsForReplica"
"description": "Contains settings that allow ClickHouse servers to interact with a Keeper cluster",
"allOf": [
{
"$ref": "#/components/schemas/KeeperConfigsForReplica"
}
]
},
"listen_host": {
"description": "Address the server is listening on",
"type": "string",
"format": "ipv6"
},
"logger": {
"$ref": "#/components/schemas/LogConfig"
"description": "Logging settings",
"allOf": [
{
"$ref": "#/components/schemas/LogConfig"
}
]
},
"macros": {
"$ref": "#/components/schemas/Macros"
"description": "Parameter substitutions for replicated tables",
"allOf": [
{
"$ref": "#/components/schemas/Macros"
}
]
},
"remote_servers": {
"$ref": "#/components/schemas/RemoteServers"
"description": "Configuration of clusters used by the Distributed table engine and bythe cluster table function",
"allOf": [
{
"$ref": "#/components/schemas/RemoteServers"
}
]
},
"tcp_port": {
"description": "Port for TCP connections",
"type": "integer",
"format": "uint16",
"minimum": 0
Expand Down Expand Up @@ -516,27 +574,37 @@
"type": "object",
"properties": {
"config_dir": {
"description": "Directory for the generated server configuration XML file",
"type": "string",
"format": "Utf8PathBuf"
},
"datastore_path": {
"description": "Directory for all files generated by ClickHouse itself",
"type": "string",
"format": "Utf8PathBuf"
},
"keepers": {
"description": "Addresses for each of the individual nodes in the Keeper cluster",
"type": "array",
"items": {
"$ref": "#/components/schemas/ClickhouseHost"
}
},
"listen_addr": {
"description": "Address the server is listening on",
"type": "string",
"format": "ipv6"
},
"node_id": {
"$ref": "#/components/schemas/ServerId"
"description": "Unique ID of the server",
"allOf": [
{
"$ref": "#/components/schemas/ServerId"
}
]
},
"remote_servers": {
"description": "Addresses for each of the individual replica servers",
"type": "array",
"items": {
"$ref": "#/components/schemas/ClickhouseHost"
Expand Down

0 comments on commit 2f7f8bd

Please sign in to comment.