#[non_exhaustive]
pub struct SessionConfig {
Show 26 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 cloud_config: Option<Arc<CloudConfig>>, pub enable_write_coalescing: bool, pub tracing_info_fetch_attempts: NonZeroU32, pub tracing_info_fetch_interval: Duration, pub tracing_info_fetch_consistency: Consistency,
}
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§ssl_context: Option<SslContext>
Available on crate feature 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.

§cloud_config: Option<Arc<CloudConfig>>
Available on crate feature cloud only.

If the driver is to connect to ScyllaCloud, there is a config for it.

§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.

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToOwned for Twhere 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 Twhere 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 Twhere 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.
§

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

§

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