Struct scylla::transport::session::SessionConfig
source · #[non_exhaustive]pub struct SessionConfig {Show 22 fields
pub known_nodes: Vec<KnownNode>,
pub compression: Option<Compression>,
pub tcp_nodelay: bool,
pub tcp_keepalive_interval: Option<Duration>,
pub default_execution_profile_handle: ExecutionProfileHandle,
pub used_keyspace: Option<String>,
pub keyspace_case_sensitive: bool,
pub ssl_context: Option<SslContext>,
pub authenticator: Option<Arc<dyn AuthenticatorProvider>>,
pub schema_agreement_interval: Duration,
pub connect_timeout: Duration,
pub connection_pool_size: PoolSize,
pub disallow_shard_aware_port: bool,
pub keyspaces_to_fetch: Vec<String>,
pub fetch_schema_metadata: bool,
pub keepalive_interval: Option<Duration>,
pub keepalive_timeout: Option<Duration>,
pub auto_await_schema_agreement_timeout: Option<Duration>,
pub address_translator: Option<Arc<dyn AddressTranslator>>,
pub host_filter: Option<Arc<dyn HostFilter>>,
pub refresh_metadata_on_auto_schema_agreement: bool,
pub enable_write_coalescing: bool,
/* private fields */
}
Expand description
Configuration options for Session
.
Can be created manually, but usually it’s easier to use
SessionBuilder
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.known_nodes: Vec<KnownNode>
List of database servers known on Session startup. Session will connect to these nodes to retrieve information about other nodes in the cluster. Each node can be represented as a hostname or an IP address.
compression: Option<Compression>
Preferred compression algorithm to use on connections. If it’s not supported by database server Session will fall back to no compression.
tcp_nodelay: bool
§tcp_keepalive_interval: Option<Duration>
§default_execution_profile_handle: ExecutionProfileHandle
§used_keyspace: Option<String>
§keyspace_case_sensitive: bool
§ssl_context: Option<SslContext>
ssl
only.Provide our Session with TLS
authenticator: Option<Arc<dyn AuthenticatorProvider>>
§schema_agreement_interval: Duration
§connect_timeout: Duration
§connection_pool_size: PoolSize
Size of the per-node connection pool, i.e. how many connections the driver should keep to each node.
The default is PerShard(1)
, which is the recommended setting for Scylla clusters.
disallow_shard_aware_port: bool
If true, prevents the driver from connecting to the shard-aware port, even if the node supports it. Generally, this options is best left as default (false).
keyspaces_to_fetch: Vec<String>
If empty, fetch all keyspaces
fetch_schema_metadata: bool
If true, full schema is fetched with every metadata refresh.
keepalive_interval: Option<Duration>
Interval of sending keepalive requests.
If None
, keepalives are never sent, so Self::keepalive_timeout
has no effect.
keepalive_timeout: Option<Duration>
Controls after what time of not receiving response to keepalives a connection is closed.
If None
, connections are never closed due to lack of response to a keepalive message.
auto_await_schema_agreement_timeout: Option<Duration>
Controls the timeout for the automatic wait for schema agreement after sending a schema-altering statement.
If None
, the automatic schema agreement is disabled.
address_translator: Option<Arc<dyn AddressTranslator>>
§host_filter: Option<Arc<dyn HostFilter>>
The host filter decides whether any connections should be opened to the node or not. The driver will also avoid filtered out nodes when re-establishing the control connection.
refresh_metadata_on_auto_schema_agreement: bool
If true, full schema metadata is fetched after successfully reaching a schema agreement. It is true by default but can be disabled if successive schema-altering statements should be performed.
enable_write_coalescing: bool
If true, the driver will inject a small delay before flushing data to the socket - by rescheduling the task that writes data to the socket. This gives the task an opportunity to collect more write requests and write them in a single syscall, increasing the efficiency.
However, this optimization may worsen latency if the rate of requests issued by the application is low, but otherwise the application is heavily loaded with other tasks on the same tokio executor. Please do performance measurements before committing to disabling this option.
Implementations§
source§impl SessionConfig
impl SessionConfig
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a SessionConfig
with default configuration
Default configuration
- Compression: None
- Load balancing policy: Token-aware Round-robin
Example
let config = SessionConfig::new();
sourcepub fn add_known_node(&mut self, hostname: impl AsRef<str>)
pub fn add_known_node(&mut self, hostname: impl AsRef<str>)
Adds a known database server with a hostname. If the port is not explicitly specified, 9042 is used as default
Example
let mut config = SessionConfig::new();
config.add_known_node("127.0.0.1");
config.add_known_node("db1.example.com:9042");
sourcepub fn add_known_node_addr(&mut self, node_addr: SocketAddr)
pub fn add_known_node_addr(&mut self, node_addr: SocketAddr)
Adds a known database server with an IP address
Example
let mut config = SessionConfig::new();
config.add_known_node_addr(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 9042));
sourcepub fn add_known_nodes(
&mut self,
hostnames: impl IntoIterator<Item = impl AsRef<str>>
)
pub fn add_known_nodes( &mut self, hostnames: impl IntoIterator<Item = impl AsRef<str>> )
Adds a list of known database server with hostnames. If the port is not explicitly specified, 9042 is used as default
Example
let mut config = SessionConfig::new();
config.add_known_nodes(&["127.0.0.1:9042", "db1.example.com"]);
sourcepub fn add_known_nodes_addr(
&mut self,
node_addrs: impl IntoIterator<Item = impl Borrow<SocketAddr>>
)
pub fn add_known_nodes_addr( &mut self, node_addrs: impl IntoIterator<Item = impl Borrow<SocketAddr>> )
Adds a list of known database servers with IP addresses
Example
let addr1 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(172, 17, 0, 3)), 9042);
let addr2 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(172, 17, 0, 4)), 9042);
let mut config = SessionConfig::new();
config.add_known_nodes_addr(&[addr1, addr2]);
Trait Implementations§
source§impl Clone for SessionConfig
impl Clone for SessionConfig
source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Default for SessionConfig
impl Default for SessionConfig
Creates default SessionConfig
, same as SessionConfig::new