-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Single-node ClickHouse database initialization
- Loading branch information
Showing
22 changed files
with
484 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
//! Single-node ClickHouse database admin binary. | ||
use anyhow::anyhow; | ||
use camino::Utf8PathBuf; | ||
use clap::Parser; | ||
use omicron_clickhouse_admin::{ClickhouseCli, Config}; | ||
use omicron_common::cmd::fatal; | ||
use omicron_common::cmd::CmdError; | ||
use std::net::{SocketAddr, SocketAddrV6}; | ||
|
||
#[derive(Debug, Parser)] | ||
#[clap( | ||
name = "clickhouse-admin-single", | ||
about = "Single-node ClickHouse admin server" | ||
)] | ||
enum Args { | ||
/// Start the single-node ClickHouse admin server | ||
Run { | ||
/// Address on which this server should run | ||
#[clap(long, short = 'a', action)] | ||
http_address: SocketAddrV6, | ||
|
||
/// Path to the server configuration file | ||
#[clap(long, short, action)] | ||
config: Utf8PathBuf, | ||
|
||
/// Address of the ClickHouse single-node database server | ||
#[clap(long, short = 'l', action)] | ||
listen_address: SocketAddrV6, | ||
|
||
/// Path to the clickhouse binary | ||
#[clap(long, short, action)] | ||
binary_path: Utf8PathBuf, | ||
}, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
if let Err(err) = main_impl().await { | ||
fatal(err); | ||
} | ||
} | ||
|
||
async fn main_impl() -> Result<(), CmdError> { | ||
let args = Args::parse(); | ||
|
||
match args { | ||
Args::Run { http_address, config, listen_address, binary_path } => { | ||
let mut config = Config::from_file(&config) | ||
.map_err(|err| CmdError::Failure(anyhow!(err)))?; | ||
config.dropshot.bind_address = SocketAddr::V6(http_address); | ||
let clickhouse_cli = | ||
ClickhouseCli::new(binary_path, listen_address); | ||
|
||
let server = omicron_clickhouse_admin::start_single_admin_server( | ||
clickhouse_cli, | ||
config, | ||
) | ||
.await | ||
.map_err(|err| CmdError::Failure(anyhow!(err)))?; | ||
server.await.map_err(|err| { | ||
CmdError::Failure(anyhow!( | ||
"server failed after starting: {err}" | ||
)) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.