Struct edgedb_tokio::Builder

source ·
pub struct Builder { /* private fields */ }
Expand description

A builder used to create connections.

Implementations§

source§

impl Builder

source

pub fn new() -> Builder

Create a builder with empty options

source

pub fn instance(&mut self, name: &str) -> Result<&mut Self, Error>

Set instance name

source

pub fn dsn(&mut self, dsn: &str) -> Result<&mut Self, Error>

Set connection parameters as DSN

source

pub fn credentials( &mut self, credentials: &Credentials ) -> Result<&mut Self, Error>

Set connection parameters as credentials structure

source

pub fn credentials_file(&mut self, path: impl AsRef<Path>) -> &mut Self

Set connection parameters from file

Note: file is not read immediately but is read when configuration is being built.

source

pub fn host(&mut self, host: &str) -> Result<&mut Self, Error>

Set host to connect to

source

pub fn port(&mut self, port: u16) -> Result<&mut Self, Error>

Set port to connect to

source

pub fn user(&mut self, user: &str) -> Result<&mut Self, Error>

Set the user name for authentication.

source

pub fn password(&mut self, password: &str) -> &mut Self

Set the password for SCRAM authentication.

source

pub fn database(&mut self, database: &str) -> Result<&mut Self, Error>

Set the database name.

source

pub fn tls_ca_file(&mut self, path: &Path) -> &mut Self

Set certificate authority for TLS from file

Note: file is not read immediately but is read when configuration is being built.

source

pub fn tls_security(&mut self, value: TlsSecurity) -> &mut Self

Updates the client TLS security mode.

By default, the certificate chain is always verified; but hostname verification is disabled if configured to use only a specific certificate, and enabled if root certificates are used.

source

pub fn client_security(&mut self, value: ClientSecurity) -> &mut Self

Modifies the client security mode.

InsecureDevMode changes tls_security only from Default to Insecure Strict ensures tls_security is also Strict

source

pub fn pem_certificates(&mut self, cert_data: &str) -> Result<&mut Self, Error>

Set the allowed certificate as a PEM file.

source

pub fn secret_key(&mut self, secret_key: &str) -> &mut Self

Set the secret key for JWT authentication.

source

pub fn wait_until_available(&mut self, time: Duration) -> &mut Self

Set the time to wait for the database server to become available.

This works by ignoring certain errors known to happen while the database is starting up or restarting (e.g. “connection refused” or early “connection reset”).

Note: the amount of time establishing a connection can take is the sum of wait_until_available plus connect_timeout

source

pub fn connect_timeout(&mut self, timeout: Duration) -> &mut Self

A timeout for a single connect attempt.

The default is 10 seconds. A subsecond timeout should be fine for most networks. However, in some cases this can be much slower. That’s because this timeout includes authentication, during which:

  • The password is checked (slow by design).
  • A compiler process is launched (slow now, may be optimized later).

So in a concurrent case on slower VMs (such as CI with parallel tests), 10 seconds is more reasonable default.

The wait_until_available setting should be larger than this value to allow multiple attempts.

Note: the amount of time establishing a connection can take is the sum of wait_until_available plus connect_timeout

source

pub fn max_concurrency(&mut self, value: usize) -> &mut Self

Set the maximum number of underlying database connections.

source

pub async fn build_env(&self) -> Result<Config, Error>

Build connection and pool configuration object

Trait Implementations§

source§

impl Clone for Builder

source§

fn clone(&self) -> Builder

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 Debug for Builder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Builder

source§

fn default() -> Builder

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, 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> Same<T> for T

§

type Output = T

Should always be Self
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