Skip to content

Commit 06c0808

Browse files
authored
[clickhouse-admin-types] reorganize per RFD 619 (#9523)
1 parent 1ac7cde commit 06c0808

File tree

41 files changed

+3288
-3019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3288
-3019
lines changed

Cargo.lock

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ members = [
66
"clickhouse-admin",
77
"clickhouse-admin/api",
88
"clickhouse-admin/test-utils",
9+
"clickhouse-admin/types/versions",
910
"clients/bootstrap-agent-client",
1011
"clients/clickhouse-admin-keeper-client",
1112
"clients/clickhouse-admin-server-client",
@@ -169,6 +170,7 @@ default-members = [
169170
"clickhouse-admin",
170171
"clickhouse-admin/api",
171172
"clickhouse-admin/types",
173+
"clickhouse-admin/types/versions",
172174
"clickhouse-admin/test-utils",
173175
"clients/bootstrap-agent-client",
174176
"clients/clickhouse-admin-keeper-client",
@@ -411,6 +413,7 @@ clickhouse-admin-keeper-client = { path = "clients/clickhouse-admin-keeper-clien
411413
clickhouse-admin-server-client = { path = "clients/clickhouse-admin-server-client" }
412414
clickhouse-admin-single-client = { path = "clients/clickhouse-admin-single-client" }
413415
clickhouse-admin-types = { path = "clickhouse-admin/types" }
416+
clickhouse-admin-types-versions = { path = "clickhouse-admin/types/versions" }
414417
clickhouse-admin-test-utils = { path = "clickhouse-admin/test-utils" }
415418
clickward = { git = "https://github.com/oxidecomputer/clickward", rev = "e3d9a1c35cf3cd04f9cb2e997b0ad88324d30737" }
416419
cockroach-admin-api = { path = "cockroach-admin/api" }

clickhouse-admin/api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ license = "MPL-2.0"
88
workspace = true
99

1010
[dependencies]
11-
clickhouse-admin-types.workspace = true
11+
clickhouse-admin-types-versions.workspace = true
1212
dropshot.workspace = true
1313
dropshot-api-manager-types.workspace = true
1414
omicron-common.workspace = true

clickhouse-admin/api/src/lib.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use clickhouse_admin_types::{
6-
ClickhouseKeeperClusterMembership, DistributedDdlQueue,
7-
GenerateConfigResult, KeeperConf, KeeperConfigurableSettings, Lgif,
8-
MetricInfoPath, RaftConfig, ServerConfigurableSettings, SystemTimeSeries,
9-
TimeSeriesSettingsQuery,
10-
};
5+
use clickhouse_admin_types_versions::latest;
116
use dropshot::{
127
HttpError, HttpResponseCreated, HttpResponseOk,
138
HttpResponseUpdatedNoContent, Path, Query, RequestContext, TypedBody,
@@ -73,8 +68,11 @@ pub trait ClickhouseAdminKeeperApi {
7368
}]
7469
async fn generate_config_and_enable_svc(
7570
rqctx: RequestContext<Self::Context>,
76-
body: TypedBody<KeeperConfigurableSettings>,
77-
) -> Result<HttpResponseCreated<GenerateConfigResult>, HttpError>;
71+
body: TypedBody<latest::keeper::KeeperConfigurableSettings>,
72+
) -> Result<
73+
HttpResponseCreated<latest::config::GenerateConfigResult>,
74+
HttpError,
75+
>;
7876

7977
/// Retrieve the generation number of a configuration
8078
#[endpoint {
@@ -94,7 +92,7 @@ pub trait ClickhouseAdminKeeperApi {
9492
}]
9593
async fn lgif(
9694
rqctx: RequestContext<Self::Context>,
97-
) -> Result<HttpResponseOk<Lgif>, HttpError>;
95+
) -> Result<HttpResponseOk<latest::keeper::Lgif>, HttpError>;
9896

9997
/// Retrieve information from ClickHouse virtual node /keeper/config which
10098
/// contains last committed cluster configuration.
@@ -104,7 +102,7 @@ pub trait ClickhouseAdminKeeperApi {
104102
}]
105103
async fn raft_config(
106104
rqctx: RequestContext<Self::Context>,
107-
) -> Result<HttpResponseOk<RaftConfig>, HttpError>;
105+
) -> Result<HttpResponseOk<latest::keeper::RaftConfig>, HttpError>;
108106

109107
/// Retrieve configuration information from a keeper node.
110108
#[endpoint {
@@ -113,7 +111,7 @@ pub trait ClickhouseAdminKeeperApi {
113111
}]
114112
async fn keeper_conf(
115113
rqctx: RequestContext<Self::Context>,
116-
) -> Result<HttpResponseOk<KeeperConf>, HttpError>;
114+
) -> Result<HttpResponseOk<latest::keeper::KeeperConf>, HttpError>;
117115

118116
/// Retrieve cluster membership information from a keeper node.
119117
#[endpoint {
@@ -122,7 +120,10 @@ pub trait ClickhouseAdminKeeperApi {
122120
}]
123121
async fn keeper_cluster_membership(
124122
rqctx: RequestContext<Self::Context>,
125-
) -> Result<HttpResponseOk<ClickhouseKeeperClusterMembership>, HttpError>;
123+
) -> Result<
124+
HttpResponseOk<latest::keeper::ClickhouseKeeperClusterMembership>,
125+
HttpError,
126+
>;
126127
}
127128

128129
/// API interface for our clickhouse-admin-server server
@@ -148,8 +149,11 @@ pub trait ClickhouseAdminServerApi {
148149
}]
149150
async fn generate_config_and_enable_svc(
150151
rqctx: RequestContext<Self::Context>,
151-
body: TypedBody<ServerConfigurableSettings>,
152-
) -> Result<HttpResponseCreated<GenerateConfigResult>, HttpError>;
152+
body: TypedBody<latest::server::ServerConfigurableSettings>,
153+
) -> Result<
154+
HttpResponseCreated<latest::config::GenerateConfigResult>,
155+
HttpError,
156+
>;
153157

154158
/// Retrieve the generation number of a configuration
155159
#[endpoint {
@@ -168,7 +172,10 @@ pub trait ClickhouseAdminServerApi {
168172
}]
169173
async fn distributed_ddl_queue(
170174
rqctx: RequestContext<Self::Context>,
171-
) -> Result<HttpResponseOk<Vec<DistributedDdlQueue>>, HttpError>;
175+
) -> Result<
176+
HttpResponseOk<Vec<latest::server::DistributedDdlQueue>>,
177+
HttpError,
178+
>;
172179

173180
/// Retrieve time series from the system database.
174181
///
@@ -181,9 +188,9 @@ pub trait ClickhouseAdminServerApi {
181188
}]
182189
async fn system_timeseries_avg(
183190
rqctx: RequestContext<Self::Context>,
184-
path_params: Path<MetricInfoPath>,
185-
query_params: Query<TimeSeriesSettingsQuery>,
186-
) -> Result<HttpResponseOk<Vec<SystemTimeSeries>>, HttpError>;
191+
path_params: Path<latest::server::MetricInfoPath>,
192+
query_params: Query<latest::server::TimeSeriesSettingsQuery>,
193+
) -> Result<HttpResponseOk<Vec<latest::server::SystemTimeSeries>>, HttpError>;
187194

188195
/// Idempotently initialize a replicated ClickHouse cluster database.
189196
#[endpoint {
@@ -225,7 +232,7 @@ pub trait ClickhouseAdminSingleApi {
225232
}]
226233
async fn system_timeseries_avg(
227234
rqctx: RequestContext<Self::Context>,
228-
path_params: Path<MetricInfoPath>,
229-
query_params: Query<TimeSeriesSettingsQuery>,
230-
) -> Result<HttpResponseOk<Vec<SystemTimeSeries>>, HttpError>;
235+
path_params: Path<latest::server::MetricInfoPath>,
236+
query_params: Query<latest::server::TimeSeriesSettingsQuery>,
237+
) -> Result<HttpResponseOk<Vec<latest::server::SystemTimeSeries>>, HttpError>;
231238
}

clickhouse-admin/src/clickhouse_cli.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
use anyhow::Result;
66
use camino::Utf8PathBuf;
7-
use clickhouse_admin_types::{
8-
ClickhouseKeeperClusterMembership, DistributedDdlQueue, KeeperConf,
9-
KeeperId, Lgif, OXIMETER_CLUSTER, RaftConfig, SystemTimeSeries,
10-
SystemTimeSeriesSettings,
7+
use clickhouse_admin_types::OXIMETER_CLUSTER;
8+
use clickhouse_admin_types::keeper::{
9+
ClickhouseKeeperClusterMembership, KeeperConf, KeeperId, Lgif, RaftConfig,
10+
};
11+
use clickhouse_admin_types::server::{
12+
DistributedDdlQueue, SystemTimeSeries, SystemTimeSeriesSettings,
1113
};
1214
use dropshot::HttpError;
1315
use illumos_utils::{ExecutionError, output_to_exec_error};

clickhouse-admin/src/clickward.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use clickhouse_admin_types::{
6-
KeeperConfig, KeeperConfigurableSettings, ReplicaConfig,
7-
ServerConfigurableSettings,
8-
};
5+
use clickhouse_admin_types::config::{KeeperConfig, ReplicaConfig};
6+
use clickhouse_admin_types::keeper::KeeperConfigurableSettings;
7+
use clickhouse_admin_types::server::ServerConfigurableSettings;
98
use dropshot::HttpError;
109
use slog_error_chain::{InlineErrorChain, SlogInlineError};
1110

clickhouse-admin/src/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ use crate::{ClickhouseCli, Clickward};
66

77
use anyhow::{Context, Result, anyhow, bail};
88
use camino::Utf8PathBuf;
9+
use clickhouse_admin_types::config::GenerateConfigResult;
10+
use clickhouse_admin_types::keeper::KeeperConfigurableSettings;
11+
use clickhouse_admin_types::server::ServerConfigurableSettings;
912
use clickhouse_admin_types::{
1013
CLICKHOUSE_KEEPER_CONFIG_DIR, CLICKHOUSE_KEEPER_CONFIG_FILE,
1114
CLICKHOUSE_SERVER_CONFIG_DIR, CLICKHOUSE_SERVER_CONFIG_FILE,
12-
GenerateConfigResult, KeeperConfigurableSettings,
13-
ServerConfigurableSettings,
1415
};
1516
use dropshot::{ClientErrorStatusCode, HttpError};
1617
use flume::{Receiver, Sender, TrySendError};

clickhouse-admin/src/http_entrypoints.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
use crate::context::{KeeperServerContext, ServerContext};
66
use clickhouse_admin_api::*;
7-
use clickhouse_admin_types::{
8-
ClickhouseKeeperClusterMembership, DistributedDdlQueue,
9-
GenerateConfigResult, KeeperConf, KeeperConfigurableSettings, Lgif,
10-
MetricInfoPath, RaftConfig, ServerConfigurableSettings, SystemTimeSeries,
11-
SystemTimeSeriesSettings, TimeSeriesSettingsQuery,
7+
use clickhouse_admin_types::config::GenerateConfigResult;
8+
use clickhouse_admin_types::keeper::{
9+
ClickhouseKeeperClusterMembership, KeeperConf, KeeperConfigurableSettings,
10+
Lgif, RaftConfig,
11+
};
12+
use clickhouse_admin_types::server::{
13+
DistributedDdlQueue, MetricInfoPath, ServerConfigurableSettings,
14+
SystemTimeSeries, SystemTimeSeriesSettings, TimeSeriesSettingsQuery,
1215
};
1316
use dropshot::{
1417
ApiDescription, ClientErrorStatusCode, HttpError, HttpResponseCreated,

clickhouse-admin/tests/integration_test.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ use clickhouse_admin_test_utils::{
88
default_clickhouse_cluster_test_deployment,
99
default_clickhouse_log_ctx_and_path,
1010
};
11-
use clickhouse_admin_types::{
12-
ClickhouseHost, ClickhouseKeeperClusterMembership, KeeperId,
13-
KeeperServerInfo, KeeperServerType, RaftConfig,
11+
use clickhouse_admin_types::config::ClickhouseHost;
12+
use clickhouse_admin_types::keeper::{
13+
ClickhouseKeeperClusterMembership, KeeperId, KeeperServerInfo,
14+
KeeperServerType, RaftConfig,
1415
};
1516
use omicron_clickhouse_admin::ClickhouseCli;
1617
use slog::{Drain, info, o};
@@ -83,7 +84,7 @@ async fn test_raft_config_parsing() -> anyhow::Result<()> {
8384
for i in 1..=num_keepers {
8485
let raft_port = get_keeper_raft_port(KeeperId(i));
8586
keeper_servers.insert(KeeperServerInfo {
86-
server_id: clickhouse_admin_types::KeeperId(i),
87+
server_id: KeeperId(i),
8788
host: ClickhouseHost::Ipv6("::1".parse().unwrap()),
8889
raft_port,
8990
server_type: KeeperServerType::Participant,

clickhouse-admin/types/Cargo.toml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,5 @@ license = "MPL-2.0"
88
workspace = true
99

1010
[dependencies]
11-
anyhow.workspace = true
12-
atomicwrites.workspace = true
13-
camino.workspace = true
14-
camino-tempfile.workspace = true
15-
chrono.workspace = true
16-
derive_more.workspace = true
17-
daft.workspace = true
18-
itertools.workspace = true
19-
omicron-common.workspace = true
11+
clickhouse-admin-types-versions.workspace = true
2012
omicron-workspace-hack.workspace = true
21-
schemars.workspace = true
22-
serde.workspace = true
23-
serde_json.workspace = true
24-
slog.workspace = true
25-
expectorate.workspace = true
26-
27-
[dev-dependencies]
28-
slog-async.workspace = true
29-
slog-term.workspace = true

0 commit comments

Comments
 (0)