Struct scylla::transport::session::SessionConfig
source · #[non_exhaustive]pub struct SessionConfig {Show 27 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 authenticator: Option<Arc<dyn AuthenticatorProvider>>,
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 schema_agreement_interval: Duration,
pub schema_agreement_timeout: Duration,
pub schema_agreement_automatic_waiting: bool,
pub refresh_metadata_on_auto_schema_agreement: bool,
pub address_translator: Option<Arc<dyn AddressTranslator>>,
pub host_filter: Option<Arc<dyn HostFilter>>,
pub enable_write_coalescing: bool,
pub tracing_info_fetch_attempts: NonZeroU32,
pub tracing_info_fetch_interval: Duration,
pub tracing_info_fetch_consistency: Consistency,
pub cluster_metadata_refresh_interval: Duration,
pub identity: SelfIdentity<'static>,
}
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
§authenticator: Option<Arc<dyn AuthenticatorProvider>>
§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.
schema_agreement_interval: Duration
How often the driver should ask if schema is in agreement.
schema_agreement_timeout: Duration
Controls the timeout for waiting for schema agreement. This works both for manual awaiting schema agreement and for automatic waiting after a schema-altering statement is sent.
schema_agreement_automatic_waiting: bool
Controls whether schema agreement is automatically awaited after sending a schema-altering statement.
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.
address_translator: Option<Arc<dyn AddressTranslator>>
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.
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.
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.
tracing_info_fetch_attempts: NonZeroU32
Number of attempts to fetch TracingInfo
in Session::get_tracing_info
. Tracing info
might not be available immediately on queried node - that’s why
the driver performs a few attempts with sleeps in between.
tracing_info_fetch_interval: Duration
Delay between attempts to fetch TracingInfo
in Session::get_tracing_info
. Tracing info
might not be available immediately on queried node - that’s why
the driver performs a few attempts with sleeps in between.
tracing_info_fetch_consistency: Consistency
Consistency level of fetching TracingInfo
in Session::get_tracing_info
.
cluster_metadata_refresh_interval: Duration
Interval between refreshing cluster metadata. This can be configured according to the traffic pattern for e.g: if they do not want unexpected traffic or they expect the topology to change frequently.
identity: SelfIdentity<'static>
Driver and application self-identifying information, to be sent to server in STARTUP message.
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
Auto Trait Implementations§
impl Freeze for SessionConfig
impl !RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl !UnwindSafe for SessionConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more