Skip to content

Commit

Permalink
Merge pull request #796 from wprzytula/translator-docstring
Browse files Browse the repository at this point in the history
session: add docstrings for AddressTranslator
  • Loading branch information
piodul authored Aug 22, 2023
2 parents 0845531 + 0b3df5b commit 148595a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scylla/src/transport/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ use crate::authentication::AuthenticatorProvider;
#[cfg(feature = "ssl")]
use openssl::ssl::SslContext;

/// Translates IP addresses received from ScyllaDB nodes into locally reachable addresses.
///
/// The driver auto-detects new ScyllaDB nodes added to the cluster through server side pushed
/// notifications and through checking the system tables. For each node, the address the driver
/// receives corresponds to the address set as `rpc_address` in the node yaml file. In most
/// cases, this is the correct address to use by the driver and that is what is used by default.
/// However, sometimes the addresses received through this mechanism will either not be reachable
/// directly by the driver or should not be the preferred address to use to reach the node (for
/// instance, the `rpc_address` set on ScyllaDB nodes might be a private IP, but some clients
/// may have to use a public IP, or pass by a router, e.g. through NAT, to reach that node).
/// This interface allows to deal with such cases, by allowing to translate an address as sent
/// by a ScyllaDB node to another address to be used by the driver for connection.
///
/// Please note that the "known nodes" addresses provided while creating the [`Session`]
/// instance are not translated, only IP address retrieved from or sent by Cassandra nodes
/// to the driver are.
#[async_trait]
pub trait AddressTranslator: Send + Sync {
async fn translate_address(
Expand Down Expand Up @@ -223,6 +239,10 @@ pub struct SessionConfig {
/// It is true by default but can be disabled if successive schema-altering statements should be performed.
pub refresh_metadata_on_auto_schema_agreement: bool,

/// The address translator is used to translate addresses received from ScyllaDB nodes
/// (either with cluster metadata or with an event) to addresses that can be used to
/// actually connect to those nodes. This may be needed e.g. when there is NAT
/// between the nodes and the driver.
pub address_translator: Option<Arc<dyn AddressTranslator>>,

/// The host filter decides whether any connections should be opened
Expand Down

0 comments on commit 148595a

Please sign in to comment.