pub struct SessionConfig {Show 17 fields
pub known_nodes: Vec<KnownNode>,
pub compression: Option<Compression>,
pub tcp_nodelay: bool,
pub load_balancing: Arc<dyn LoadBalancingPolicy>,
pub used_keyspace: Option<String>,
pub keyspace_case_sensitive: bool,
pub retry_policy: Box<dyn RetryPolicy>,
pub speculative_execution_policy: Option<Arc<dyn SpeculativeExecutionPolicy>>,
pub auth_username: Option<String>,
pub auth_password: Option<String>,
pub schema_agreement_interval: Duration,
pub connect_timeout: Duration,
pub connection_pool_size: PoolSize,
pub disallow_shard_aware_port: bool,
pub default_consistency: Consistency,
pub fetch_schema_metadata: bool,
pub keepalive_interval: Option<Duration>,
}
Expand description
Configuration options for Session
.
Can be created manually, but usually it’s easier to use
SessionBuilder
Fields
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
load_balancing: Arc<dyn LoadBalancingPolicy>
Load balancing policy used by Session
used_keyspace: Option<String>
keyspace_case_sensitive: bool
retry_policy: Box<dyn RetryPolicy>
speculative_execution_policy: Option<Arc<dyn SpeculativeExecutionPolicy>>
auth_username: Option<String>
auth_password: Option<String>
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).
default_consistency: Consistency
fetch_schema_metadata: bool
If true, full schema is fetched with every metadata refresh.
keepalive_interval: Option<Duration>
Interval of sending keepalive requests
Implementations
sourceimpl 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 AsRef<str>])
pub fn add_known_nodes(&mut self, hostnames: &[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: &[SocketAddr])
pub fn add_known_nodes_addr(&mut self, node_addrs: &[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
sourceimpl Clone for SessionConfig
impl Clone for SessionConfig
sourcefn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Default for SessionConfig
impl Default for SessionConfig
Creates default SessionConfig
, same as SessionConfig::new
Auto Trait Implementations
impl !RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl !UnwindSafe for SessionConfig
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more