diff --git a/crates/sdk/examples/quickstart-chat/main.rs b/crates/sdk/examples/quickstart-chat/main.rs index e04ff9cb3cc..33e926db2e4 100644 --- a/crates/sdk/examples/quickstart-chat/main.rs +++ b/crates/sdk/examples/quickstart-chat/main.rs @@ -29,7 +29,7 @@ fn main() { /// The URI of the SpacetimeDB instance hosting our chat module. const HOST: &str = "http://localhost:3000"; -/// The module name we chose when we published our module. +/// The database name we chose when we published our module. const DB_NAME: &str = "quickstart-chat"; /// Load credentials from a file and connect to the database. @@ -46,7 +46,7 @@ fn connect_to_db() -> DbConnection { // so we can re-authenticate as the same `Identity`. .with_token(creds_store().load().expect("Error loading credentials")) // Set the database name we chose when we called `spacetime publish`. - .with_module_name(DB_NAME) + .with_database_name(DB_NAME) // Set the URI of the SpacetimeDB host that's running our database. .with_uri(HOST) // Finalize configuration and connect! diff --git a/crates/sdk/src/db_connection.rs b/crates/sdk/src/db_connection.rs index e1e4133e3ca..e45b15ca678 100644 --- a/crates/sdk/src/db_connection.rs +++ b/crates/sdk/src/db_connection.rs @@ -739,7 +739,7 @@ impl CallReducerFlagsMap { pub struct DbConnectionBuilder { uri: Option, - module_name: Option, + database_name: Option, token: Option, @@ -788,7 +788,7 @@ impl DbConnectionBuilder { pub fn new() -> Self { Self { uri: None, - module_name: None, + database_name: None, token: None, on_connect: None, on_connect_error: None, @@ -807,7 +807,7 @@ impl DbConnectionBuilder { /// the connection may still fail asynchronously, /// leading to the [`Self::on_connect_error`] callback being invoked. /// - /// Before calling this method, make sure to invoke at least [`Self::with_uri`] and [`Self::with_module_name`] + /// Before calling this method, make sure to invoke at least [`Self::with_uri`] and [`Self::with_database_name`] /// to configure the connection. #[must_use = " You must explicitly advance the connection by calling any one of: @@ -837,7 +837,7 @@ but you must call one of them, or else the connection will never progress. let ws_connection = tokio::task::block_in_place(|| { handle.block_on(WsConnection::connect( self.uri.unwrap(), - self.module_name.as_ref().unwrap(), + self.database_name.as_ref().unwrap(), self.token.as_deref(), get_connection_id(), self.params, @@ -892,9 +892,19 @@ but you must call one of them, or else the connection will never progress. self } - /// Set the name or identity of the remote module. + /// Set the name or identity of the remote database. + #[deprecated( + since = "1.0.2", + note = "You should instead use [`DbConnectionBuilder::with_module_name`]." + )] pub fn with_module_name(mut self, name_or_identity: impl Into) -> Self { - self.module_name = Some(name_or_identity.into()); + self.database_name = Some(name_or_identity.into()); + self + } + + /// Set the name or identity of the remote database. + pub fn with_database_name(mut self, name_or_identity: impl Into) -> Self { + self.database_name = Some(name_or_identity.into()); self } diff --git a/crates/sdk/tests/connect_disconnect_client/src/main.rs b/crates/sdk/tests/connect_disconnect_client/src/main.rs index de9e9dd3fba..772e0624cc6 100644 --- a/crates/sdk/tests/connect_disconnect_client/src/main.rs +++ b/crates/sdk/tests/connect_disconnect_client/src/main.rs @@ -21,7 +21,7 @@ fn main() { let sub_applied_one_row_result = connect_test_counter.add_test("connected_row"); let connection = DbConnection::builder() - .with_module_name(db_name_or_panic()) + .with_database_name(db_name_or_panic()) .with_uri(LOCALHOST) .on_connect_error(|_ctx, error| panic!("on_connect_error: {:?}", error)) .on_connect(move |ctx, _, _| { @@ -75,7 +75,7 @@ fn main() { .on_connect(move |_ctx, _, _| { reconnected_result(Ok(())); }) - .with_module_name(db_name_or_panic()) + .with_database_name(db_name_or_panic()) .with_uri(LOCALHOST) .build() .unwrap(); diff --git a/crates/sdk/tests/test-client/src/main.rs b/crates/sdk/tests/test-client/src/main.rs index db75fd13842..d58e45129f7 100644 --- a/crates/sdk/tests/test-client/src/main.rs +++ b/crates/sdk/tests/test-client/src/main.rs @@ -1663,7 +1663,7 @@ fn exec_reauth_part_1() { save_result(creds_store().save(token).map_err(Into::into)); }) .on_connect_error(|_ctx, error| panic!("Connect failed: {:?}", error)) - .with_module_name(name) + .with_database_name(name) .with_uri(LOCALHOST) .build() .unwrap() @@ -1697,7 +1697,7 @@ fn exec_reauth_part_2() { } }) .on_connect_error(|_ctx, error| panic!("Connect failed: {:?}", error)) - .with_module_name(name) + .with_database_name(name) .with_token(Some(token)) .with_uri(LOCALHOST) .build() @@ -1715,7 +1715,7 @@ fn exec_reconnect_same_connection_id() { let disconnect_result = disconnect_test_counter.add_test("disconnect"); let initial_connection = DbConnection::builder() - .with_module_name(db_name_or_panic()) + .with_database_name(db_name_or_panic()) .with_uri(LOCALHOST) .on_connect_error(|_ctx, error| panic!("on_connect_error: {:?}", error)) .on_connect(move |_, _, _| { @@ -1743,7 +1743,7 @@ fn exec_reconnect_same_connection_id() { let addr_after_reconnect_result = reconnect_test_counter.add_test("addr_after_reconnect"); let re_connection = DbConnection::builder() - .with_module_name(db_name_or_panic()) + .with_database_name(db_name_or_panic()) .with_uri(LOCALHOST) .on_connect_error(|_ctx, error| panic!("on_connect_error: {:?}", error)) .on_connect(move |ctx, _, _| {