Skip to content

Commit

Permalink
rename feature: cloud -> unstable-cloud
Browse files Browse the repository at this point in the history
As the Serverless Cloud is a highly unstable feature, it must be marked
as such in order not to break API after 1.0 in case we need to introduce
breaking changes to the feature.
  • Loading branch information
wprzytula committed Feb 3, 2025
1 parent c3a42a6 commit 37d91f5
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rustyline-derive = "0.6"
scylla = { path = "../scylla", features = [
"openssl-010",
"rustls-023",
"cloud",
"unstable-cloud",
"chrono-04",
"time-03",
"num-bigint-03",
Expand Down
2 changes: 1 addition & 1 deletion scylla/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
default = []
openssl-010 = ["dep:tokio-openssl", "dep:openssl", "__tls"]
rustls-023 = ["dep:tokio-rustls", "dep:rustls", "__tls"]
cloud = [
unstable-cloud = [
"__tls",
"scylla-cql/serde",
"dep:serde_yaml",
Expand Down
18 changes: 9 additions & 9 deletions scylla/src/client/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use super::{Compression, PoolSize, SelfIdentity};
use crate::authentication::AuthenticatorProvider;
use crate::batch::batch_values;
use crate::batch::{Batch, BatchStatement};
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use crate::cloud::CloudConfig;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use crate::cluster::node::CloudEndpoint;
use crate::cluster::node::{InternalKnownNode, KnownNode, NodeRef};
use crate::cluster::{Cluster, ClusterNeatDebug, ClusterState};
Expand Down Expand Up @@ -56,7 +56,7 @@ use std::num::NonZeroU32;
use std::sync::Arc;
use std::time::Duration;
use tokio::time::timeout;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use tracing::warn;
use tracing::{debug, error, trace, trace_span, Instrument};
use uuid::Uuid;
Expand Down Expand Up @@ -252,7 +252,7 @@ pub struct SessionConfig {
pub host_filter: Option<Arc<dyn HostFilter>>,

/// If the driver is to connect to ScyllaCloud, there is a config for it.
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
pub cloud_config: Option<Arc<CloudConfig>>,

/// If true, the driver will inject a small delay before flushing data
Expand Down Expand Up @@ -332,7 +332,7 @@ impl SessionConfig {
address_translator: None,
host_filter: None,
refresh_metadata_on_auto_schema_agreement: true,
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
cloud_config: None,
enable_write_coalescing: true,
tracing_info_fetch_attempts: NonZeroU32::new(10).unwrap(),
Expand Down Expand Up @@ -977,7 +977,7 @@ where
pub async fn connect(config: SessionConfig) -> Result<Self, NewSessionError> {
let known_nodes = config.known_nodes;

#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
let cloud_known_nodes: Option<Vec<InternalKnownNode>> =
if let Some(ref cloud_config) = config.cloud_config {
let cloud_servers = cloud_config
Expand All @@ -995,7 +995,7 @@ where
None
};

#[cfg(not(feature = "cloud"))]
#[cfg(not(feature = "unstable-cloud"))]
let cloud_known_nodes: Option<Vec<InternalKnownNode>> = None;

let known_nodes = cloud_known_nodes
Expand All @@ -1010,7 +1010,7 @@ where

#[allow(unused_labels)] // Triggers when `cloud` feature is disabled.
let address_translator = 'translator: {
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
if let Some(translator) = config.cloud_config.clone() {
if config.address_translator.is_some() {
// This can only happen if the user builds SessionConfig by hand, as SessionBuilder in cloud mode prevents setting custom AddressTranslator.
Expand All @@ -1029,7 +1029,7 @@ where

#[cfg(feature = "__tls")]
let tls_provider = 'provider: {
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
if let Some(cloud_config) = config.cloud_config {
if config.tls_context.is_some() {
// This can only happen if the user builds SessionConfig by hand, as SessionBuilder in cloud mode prevents setting custom TlsContext.
Expand Down
16 changes: 8 additions & 8 deletions scylla/src/client/session_builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! SessionBuilder provides an easy way to create new Sessions
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use super::execution_profile::ExecutionProfile;
use super::execution_profile::ExecutionProfileHandle;
#[allow(deprecated)]
Expand All @@ -11,7 +11,7 @@ use super::{Compression, PoolSize, SelfIdentity};
use crate::authentication::{AuthenticatorProvider, PlainTextAuthenticator};
#[cfg(feature = "__tls")]
use crate::client::session::TlsContext;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use crate::cloud::{CloudConfig, CloudConfigError};
use crate::errors::NewSessionError;
use crate::policies::address_translator::AddressTranslator;
Expand All @@ -22,7 +22,7 @@ use std::borrow::Borrow;
use std::marker::PhantomData;
use std::net::SocketAddr;
use std::num::NonZeroU32;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
Expand All @@ -44,15 +44,15 @@ impl SessionBuilderKind for DefaultMode {}

pub type SessionBuilder = GenericSessionBuilder<DefaultMode>;

#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
#[derive(Clone)]
pub enum CloudMode {}
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
impl sealed::Sealed for CloudMode {}
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
impl SessionBuilderKind for CloudMode {}

#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
pub type CloudSessionBuilder = GenericSessionBuilder<CloudMode>;

/// SessionBuilder is used to create new Session instances
Expand Down Expand Up @@ -365,7 +365,7 @@ impl GenericSessionBuilder<DefaultMode> {
// NOTE: this `impl` block contains configuration options specific for **Cloud** [`Session`].
// This means that if an option fits both non-Cloud and Cloud `Session`s, it should NOT be put
// here, but rather in `impl<K> GenericSessionBuilder<K>` block.
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
impl CloudSessionBuilder {
/// Creates a new SessionBuilder with default configuration,
/// based on provided path to Scylla Cloud Config yaml.
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/cloud/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pub use config::CloudConfig;
pub use config::CloudConfigError;

#[cfg(all(
feature = "cloud",
feature = "unstable-cloud",
not(any(feature = "rustls-023", feature = "openssl-010"))
))]
compile_error!(
r#""cloud" feature requires a TLS backend: at least one of ["rustls-023", "openssl-010"] is needed"#
r#""unstable-cloud" feature requires a TLS backend: at least one of ["rustls-023", "openssl-010"] is needed"#
);
8 changes: 4 additions & 4 deletions scylla/src/cluster/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub enum KnownNode {
pub(crate) enum InternalKnownNode {
Hostname(String),
Address(SocketAddr),
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
CloudEndpoint(CloudEndpoint),
}

Expand All @@ -252,7 +252,7 @@ impl From<KnownNode> for InternalKnownNode {
}

/// Describes a database server in the serverless Scylla Cloud.
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub(crate) struct CloudEndpoint {
pub(crate) hostname: String,
Expand All @@ -263,7 +263,7 @@ pub(crate) struct CloudEndpoint {
#[derive(Debug, Clone)]
pub(crate) struct ResolvedContactPoint {
pub(crate) address: SocketAddr,
#[cfg_attr(not(feature = "cloud"), allow(unused))]
#[cfg_attr(not(feature = "unstable-cloud"), allow(unused))]
pub(crate) datacenter: Option<String>,
}

Expand Down Expand Up @@ -313,7 +313,7 @@ pub(crate) async fn resolve_contact_points(
address: *address,
datacenter: None,
}),
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
InternalKnownNode::CloudEndpoint(CloudEndpoint {
hostname,
datacenter,
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub mod deserialize {

pub mod authentication;
pub mod client;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
pub mod cloud;

pub mod cluster;
Expand Down
40 changes: 20 additions & 20 deletions scylla/src/network/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,28 +236,28 @@ mod tls_config {
);

use std::io;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use std::sync::Arc;

#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use tracing::warn;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use uuid::Uuid;

use crate::client::session::TlsContext;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use crate::cloud::CloudConfig;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use crate::cluster::metadata::PeerEndpoint;
use crate::cluster::metadata::UntranslatedEndpoint;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
use crate::cluster::node::ResolvedContactPoint;

/// Abstraction capable of producing TlsConfig for connections on-demand.
#[derive(Clone)] // Cheaply clonable (reference-counted)
pub(crate) enum TlsProvider {
GlobalContext(TlsContext),
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
ScyllaCloud(Arc<CloudConfig>),
}

Expand All @@ -268,7 +268,7 @@ mod tls_config {
}

// Used in the cloud case.
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
pub(crate) fn new_cloud(cloud_config: Arc<CloudConfig>) -> Self {
Self::ScyllaCloud(cloud_config)
}
Expand All @@ -281,7 +281,7 @@ mod tls_config {
TlsProvider::GlobalContext(context) => {
Some(TlsConfig::new_with_global_context(context.clone()))
}
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
TlsProvider::ScyllaCloud(cloud_config) => {
let (host_id, address, dc) = match *endpoint {
UntranslatedEndpoint::ContactPoint(ResolvedContactPoint {
Expand Down Expand Up @@ -326,7 +326,7 @@ mod tls_config {
#[derive(Clone)]
pub(crate) struct TlsConfig {
context: TlsContext,
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
sni: Option<String>,
}

Expand All @@ -336,7 +336,7 @@ mod tls_config {
#[cfg(feature = "rustls-023")]
Rustls023 {
connector: tokio_rustls::TlsConnector,
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
sni: Option<rustls::pki_types::ServerName<'static>>,
},
}
Expand Down Expand Up @@ -406,21 +406,21 @@ mod tls_config {
pub(crate) fn new_with_global_context(context: TlsContext) -> Self {
Self {
context,
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
sni: None,
}
}

// Used in case of Serverless Cloud connections.
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
pub(crate) fn new_for_sni(
context: TlsContext,
domain_name: &str,
host_id: Option<Uuid>,
) -> Self {
Self {
context,
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
sni: Some(if let Some(host_id) = host_id {
format!("{}.{}", host_id, domain_name)
} else {
Expand All @@ -436,7 +436,7 @@ mod tls_config {
TlsContext::OpenSsl010(context) => {
#[allow(unused_mut)]
let mut ssl = openssl::ssl::Ssl::new(context)?;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
if let Some(sni) = self.sni.as_ref() {
ssl.set_hostname(sni)?;
}
Expand All @@ -445,7 +445,7 @@ mod tls_config {
#[cfg(feature = "rustls-023")]
TlsContext::Rustls023(config) => {
let connector = tokio_rustls::TlsConnector::from(config.clone());
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
let sni = self
.sni
.as_deref()
Expand All @@ -455,7 +455,7 @@ mod tls_config {

Tls::Rustls023 {
connector,
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
sni,
}
}
Expand Down Expand Up @@ -1641,14 +1641,14 @@ impl Connection {
#[cfg(feature = "rustls-023")]
Tls::Rustls023 {
connector,
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
sni,
} => {
use rustls::pki_types::ServerName;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
let server_name =
sni.unwrap_or_else(|| ServerName::IpAddress(node_address.into()));
#[cfg(not(feature = "cloud"))]
#[cfg(not(feature = "unstable-cloud"))]
let server_name = ServerName::IpAddress(node_address.into());
let stream = connector.connect(server_name, stream).await?;
let (task, handle) = Self::router(
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! - NodeConnectionPool - a manager that keeps a desired number of connections opened to each shard.
mod connection;
#[cfg(feature = "cloud")]
#[cfg(feature = "unstable-cloud")]
pub(crate) use connection::TlsConfig;
#[cfg(feature = "__tls")]
pub use connection::TlsError;
Expand Down

0 comments on commit 37d91f5

Please sign in to comment.