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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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

source

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();
source

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");
source

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));
source

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"]);
source

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

source§

fn clone(&self) -> SessionConfig

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for SessionConfig

Creates default SessionConfig, same as SessionConfig::new

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,