pub trait AddressTranslator: Send + Sync {
// Required method
fn translate_address<'life0, 'life1, 'async_trait>(
&'life0 self,
untranslated_peer: &'life1 UntranslatedPeer,
) -> Pin<Box<dyn Future<Output = Result<SocketAddr, TranslationError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
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.