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

A builder used to create connections.

Implementations

Initializes a Builder using environment variables or project config.

Reads the project config if it exists.

Projects are initialized using the command-line tool:

edgedb project init

Linking to an already running EdgeDB is also possible:

edgedb project init --link

Returns a boolean value indicating whether the project was found.

Indicates whether credentials are set for this builder.

Read environment variables and set respective configuration parameters.

This function initializes the builder if one of the following is set:

  • EDGEDB_CREDENTIALS_FILE
  • EDGEDB_INSTANCE
  • EDGEDB_DSN
  • EDGEDB_HOST or EDGEDB_PORT

If it finds one of these then it will reset all previously set credentials.

If one of the following are set:

  • EDGEDB_DATABASE
  • EDGEDB_USER
  • EDGEDB_PASSWORD

Then the value of that environment variable will be used to set just the parameter matching that environment variable.

The insecure_dev_mode and connection parameters are never modified by this function for now.

Read environment variables that aren’t credentials

Set all credentials.

This marks the builder as initialized.

Read credentials from the named instance.

Named instances are created using the command-line tool, either directly:

edgedb instance create <name>

or when initializing a project:

edgedb project init

In the latter case you should use read_project() instead if possible.

This will mark the builder as initialized (if reading is successful) and overwrite all credentials. However, insecure_dev_mode, pools sizes, and timeouts are kept intact.

Read credentials from a file.

This will mark the builder as initialized (if reading is successful) and overwrite all credentials. However, insecure_dev_mode, pools sizes, and timeouts are kept intact.

Initialize credentials using data source name (DSN).

DSN’s that EdgeDB like are URL with egdgedb::/scheme:

edgedb://user:secret@localhost:5656/

All the credentials can be specified using a DSN, although parsing a DSN may also lead to reading of environment variables (if query arguments of the for *_env are specified) and local files (for query arguments named *_file).

This will mark the builder as initialized (if reading is successful) and overwrite all the credentials. However, insecure_dev_mode, pools sizes, and timeouts are kept intact.

Creates a new builder that has to be intialized by calling some methods.

This is only useful if you have connections to multiple unrelated databases, or you want to have total control of the database initialization process.

Usually, Builder::from_env() should be used instead.

Extract credentials from the Builder so they can be saved as JSON.

Get the host this builder is configured to connect to.

For unix-socket-configured builder (only if admin_socket feature is enabled) returns “localhost”

Get the port this builder is configured to connect to.

Initialize credentials using host/port data.

If either of host or port is None, they are replaced with the default of localhost and 5656 respectively.

This will mark the builder as initialized and overwrite all the credentials. However, insecure_dev_mode, pools sizes, and timeouts are kept intact.

Get the user name for SCRAM authentication.

Set the user name for SCRAM authentication.

Set the password for SCRAM authentication.

Set the database name.

Get the database name.

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

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

Set the allowed certificate as a PEM file.

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.

Enables insecure dev mode.

This disables certificate validation entirely.

A displayable form for an address this builder will connect to

Build connection and pool configuration object

Set the maximum number of underlying database connections.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

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)

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.