Struct scylla::transport::session::SessionConfig[][src]

pub struct SessionConfig {
    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,
}
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: boolload_balancing: Arc<dyn LoadBalancingPolicy>

Load balancing policy used by Session

used_keyspace: Option<String>keyspace_case_sensitive: boolretry_policy: Box<dyn RetryPolicy>speculative_execution_policy: Option<Arc<dyn SpeculativeExecutionPolicy>>auth_username: Option<String>auth_password: Option<String>schema_agreement_interval: Durationconnect_timeout: Duration

Implementations

Creates a SessionConfig with default configuration

Default configuration

  • Compression: None
  • Load balancing policy: Token-aware Round-robin

Example

let config = SessionConfig::new();

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

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

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Creates default SessionConfig, same as SessionConfig::new

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.