-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
033b118
commit d41ae57
Showing
11 changed files
with
170 additions
and
68 deletions.
There are no files selected for viewing
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,47 @@ | ||
// 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/. | ||
|
||
//! Queries related to clickhouse policy | ||
|
||
use super::DataStore; | ||
use crate::authz; | ||
use crate::context::OpContext; | ||
use crate::db; | ||
use crate::db::error::public_error_from_diesel; | ||
use crate::db::error::ErrorHandler; | ||
use crate::db::pagination::paginated; | ||
use async_bb8_diesel::AsyncRunQueryDsl; | ||
use diesel::expression::SelectableHelper; | ||
use diesel::QueryDsl; | ||
use nexus_db_model::ClickhousePolicy as DbClickhousePolicy; | ||
use nexus_db_model::SqlU32; | ||
use nexus_types::deployment::ClickhousePolicy; | ||
use omicron_common::api::external::DataPageParams; | ||
use omicron_common::api::external::ListResultVec; | ||
|
||
impl DataStore { | ||
pub async fn clickhouse_policy_list( | ||
&self, | ||
opctx: &OpContext, | ||
pagparams: &DataPageParams<'_, SqlU32>, | ||
) -> ListResultVec<Option<ClickhousePolicy>> { | ||
use db::schema::clickhouse_policy; | ||
|
||
opctx | ||
.authorize(authz::Action::ListChildren, &authz::BLUEPRINT_CONFIG) | ||
.await?; | ||
|
||
let policies = paginated( | ||
clickhouse_policy::table, | ||
clickhouse_policy::version, | ||
pagparams, | ||
) | ||
.select(DbClickhousePolicy::as_select()) | ||
.get_results_async(&*self.pool_connection_authorized(opctx).await?) | ||
.await | ||
.map_err(|e| public_error_from_diesel(e, ErrorHandler::Server))?; | ||
|
||
Ok(policies.into_iter().map(|p| p.into_clickhouse_policy).collect()) | ||
} | ||
} |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TYPE IF NOT EXISTS omicron.public.clickhouse_mode AS ENUM ( | ||
'single_node_only', | ||
'cluster_only', | ||
'both' | ||
); |
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,7 @@ | ||
CREATE TABLE IF NOT EXISTS omicron.public.clickhouse_policy ( | ||
version INT8 PRIMARY KEY, | ||
clickhouse_mode omicron.public.clickhouse_mode NOT NULL, | ||
clickhouse_cluster_target_servers INT2 NOT NULL, | ||
clickhouse_cluster_target_keepers INT2 NOT NULL, | ||
time_created TIMESTAMPTZ NOT NULL | ||
); |
Oops, something went wrong.