Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce orchestratord deps #30842

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"src/catalog-debug",
"src/catalog-protos",
"src/cloud-api",
"src/cloud-provider",
"src/cluster",
"src/clusterd",
"src/cluster-client",
Expand Down Expand Up @@ -134,6 +135,7 @@ default-members = [
"src/catalog-protos",
"src/ccsr",
"src/cloud-api",
"src/cloud-provider",
"src/cloud-resources",
"src/cluster",
"src/cluster-client",
Expand Down
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ crates_repository(
"//:src/catalog/Cargo.toml",
"//:src/ccsr/Cargo.toml",
"//:src/cloud-api/Cargo.toml",
"//:src/cloud-provider/Cargo.toml",
"//:src/cloud-resources/Cargo.toml",
"//:src/cluster-client/Cargo.toml",
"//:src/cluster/Cargo.toml",
Expand Down
6 changes: 6 additions & 0 deletions src/adapter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ rust_library(
"//src/build-info:mz_build_info",
"//src/catalog:mz_catalog",
"//src/ccsr:mz_ccsr",
"//src/cloud-provider:mz_cloud_provider",
"//src/cloud-resources:mz_cloud_resources",
"//src/cluster-client:mz_cluster_client",
"//src/compute-client:mz_compute_client",
Expand Down Expand Up @@ -104,6 +105,7 @@ rust_test(
"//src/build-info:mz_build_info",
"//src/catalog:mz_catalog",
"//src/ccsr:mz_ccsr",
"//src/cloud-provider:mz_cloud_provider",
"//src/cloud-resources:mz_cloud_resources",
"//src/cluster-client:mz_cluster_client",
"//src/compute-client:mz_compute_client",
Expand Down Expand Up @@ -153,6 +155,7 @@ rust_doc_test(
"//src/build-info:mz_build_info",
"//src/catalog:mz_catalog",
"//src/ccsr:mz_ccsr",
"//src/cloud-provider:mz_cloud_provider",
"//src/cloud-resources:mz_cloud_resources",
"//src/cluster-client:mz_cluster_client",
"//src/compute-client:mz_compute_client",
Expand Down Expand Up @@ -222,6 +225,7 @@ rust_test(
"//src/build-info:mz_build_info",
"//src/catalog:mz_catalog",
"//src/ccsr:mz_ccsr",
"//src/cloud-provider:mz_cloud_provider",
"//src/cloud-resources:mz_cloud_resources",
"//src/cluster-client:mz_cluster_client",
"//src/compute-client:mz_compute_client",
Expand Down Expand Up @@ -291,6 +295,7 @@ rust_test(
"//src/build-info:mz_build_info",
"//src/catalog:mz_catalog",
"//src/ccsr:mz_ccsr",
"//src/cloud-provider:mz_cloud_provider",
"//src/cloud-resources:mz_cloud_resources",
"//src/cluster-client:mz_cluster_client",
"//src/compute-client:mz_compute_client",
Expand Down Expand Up @@ -360,6 +365,7 @@ rust_test(
"//src/build-info:mz_build_info",
"//src/catalog:mz_catalog",
"//src/ccsr:mz_ccsr",
"//src/cloud-provider:mz_cloud_provider",
"//src/cloud-resources:mz_cloud_resources",
"//src/cluster-client:mz_cluster_client",
"//src/compute-client:mz_compute_client",
Expand Down
1 change: 1 addition & 0 deletions src/adapter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ mz-audit-log = { path = "../audit-log" }
mz-build-info = { path = "../build-info" }
mz-catalog = { path = "../catalog" }
mz-ccsr = { path = "../ccsr" }
mz-cloud-provider = { path = "../cloud-provider", default-features = false }
mz-cloud-resources = { path = "../cloud-resources" }
mz-cluster-client = { path = "../cluster-client" }
mz-compute-client = { path = "../compute-client" }
Expand Down
3 changes: 2 additions & 1 deletion src/adapter/src/config/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ use std::time::Duration;
use derivative::Derivative;
use launchdarkly_server_sdk as ld;
use mz_build_info::BuildInfo;
use mz_cloud_provider::CloudProvider;
use mz_ore::now::NowFn;
use mz_sql::catalog::{CloudProvider, EnvironmentId};
use mz_sql::catalog::EnvironmentId;
use tokio::time;

use crate::config::{Metrics, SynchronizedParameters, SystemParameterSyncConfig};
Expand Down
73 changes: 73 additions & 0 deletions src/cloud-provider/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Code generated by cargo-gazelle DO NOT EDIT

# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

load("@crates_io//:defs.bzl", "aliases", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_doc_test", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])

rust_library(
name = "mz_cloud_provider",
srcs = glob(["src/**/*.rs"]),
aliases = aliases(
normal = True,
proc_macro = True,
),
compile_data = [],
crate_features = ["default"],
data = [],
proc_macro_deps = [] + all_crate_deps(proc_macro = True),
rustc_env = {},
rustc_flags = [],
version = "0.1.0",
deps = [] + all_crate_deps(normal = True),
)

alias(
name = "cloud-provider",
actual = "mz_cloud_provider",
)

rust_test(
name = "mz_cloud_provider_lib_tests",
size = "medium",
aliases = aliases(
normal = True,
normal_dev = True,
proc_macro = True,
proc_macro_dev = True,
),
compile_data = [],
crate = ":mz_cloud_provider",
crate_features = ["default"],
data = [],
env = {},
proc_macro_deps = [] + all_crate_deps(
proc_macro = True,
proc_macro_dev = True,
),
rustc_env = {},
rustc_flags = [],
version = "0.1.0",
deps = [] + all_crate_deps(
normal = True,
normal_dev = True,
),
)

rust_doc_test(
name = "mz_cloud_provider_doc_test",
crate = ":mz_cloud_provider",
deps = [] + all_crate_deps(
normal = True,
normal_dev = True,
),
)
18 changes: 18 additions & 0 deletions src/cloud-provider/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "mz-cloud-provider"
description = "Representation of a cloud provider"
version = "0.1.0"
authors = ["Materialize, Inc."]
license = "proprietary"
edition.workspace = true
rust-version.workspace = true
publish = false

[dependencies]
workspace-hack = { version = "0.0.0", path = "../workspace-hack", optional = true }

[features]
default = ["workspace-hack"]

[lints]
workspace = true
85 changes: 85 additions & 0 deletions src/cloud-provider/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0.

use std::fmt;
use std::str::FromStr;

/// Identifies a supported cloud provider.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CloudProvider {
/// A pseudo-provider value used by local development environments.
Local,
/// A pseudo-provider value used by Docker.
Docker,
/// A deprecated psuedo-provider value used by mzcompose.
// TODO(benesch): remove once v0.39 ships.
MzCompose,
/// A pseudo-provider value used by cloudtest.
Cloudtest,
/// Amazon Web Services.
Aws,
/// Google Cloud Platform
Gcp,
/// Microsoft Azure
Azure,
/// Other generic cloud provider
Generic,
}

impl CloudProvider {
/// Returns true if this provider actually runs in the cloud
pub fn is_cloud(&self) -> bool {
matches!(self, Self::Aws | Self::Gcp | Self::Azure | Self::Generic)
}
}

impl fmt::Display for CloudProvider {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
CloudProvider::Local => f.write_str("local"),
CloudProvider::Docker => f.write_str("docker"),
CloudProvider::MzCompose => f.write_str("mzcompose"),
CloudProvider::Cloudtest => f.write_str("cloudtest"),
CloudProvider::Aws => f.write_str("aws"),
CloudProvider::Gcp => f.write_str("gcp"),
CloudProvider::Azure => f.write_str("azure"),
CloudProvider::Generic => f.write_str("generic"),
}
}
}

impl FromStr for CloudProvider {
type Err = InvalidCloudProviderError;

fn from_str(s: &str) -> Result<CloudProvider, InvalidCloudProviderError> {
match s.to_lowercase().as_ref() {
"local" => Ok(CloudProvider::Local),
"docker" => Ok(CloudProvider::Docker),
"mzcompose" => Ok(CloudProvider::MzCompose),
"cloudtest" => Ok(CloudProvider::Cloudtest),
"aws" => Ok(CloudProvider::Aws),
"gcp" => Ok(CloudProvider::Gcp),
"azure" => Ok(CloudProvider::Azure),
"generic" => Ok(CloudProvider::Generic),
_ => Err(InvalidCloudProviderError),
}
}
}

/// The error type for [`CloudProvider::from_str`].
#[derive(Debug, Clone, PartialEq)]
pub struct InvalidCloudProviderError;

impl fmt::Display for InvalidCloudProviderError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("invalid cloud provider")
}
}

impl std::error::Error for InvalidCloudProviderError {}
Loading
Loading