Expand description
Database client for mz-deploy.
This module provides the main Client struct for interacting with Materialize.
The client handles connection management and delegates specialized operations
to domain-specific sub-clients.
ยงSub-Client Architecture
Operations are grouped into domain sub-clients accessed via accessor methods
on Client. Each sub-client borrows the Client and provides a focused API:
| Sub-client | Accessor | Responsibility |
|---|---|---|
DeploymentsClient | .deployments() | Deployment lifecycle (stage, promote, abort) |
DeploymentsClientMut | .deployments_mut() | Mutable deployment ops (SUBSCRIBE cursors) |
IntrospectionClient | .introspection() | Read-only catalog metadata queries |
ValidationClient | .validation() | Pre-deployment environment checks |
TypeInfoClient | .types() | Column/type introspection for type checking |
ProvisioningClient | .provisioning() | Idempotent DDL for databases, schemas, clusters |
ยงTLS Policy
Per-profile sslmode with libpq semantics (disable, prefer, require,
verify-ca, verify-full). When unset, loopback hosts default to
prefer and everything else defaults to require. See the design at
docs/superpowers/specs/2026-04-22-profile-tls-design.md for the behavior
table and migration notes.
Structsยง
- Client
- Database client for interacting with Materialize.
- Deployments
Client - Domain sub-client for deployment lifecycle operations.
- Deployments
Client Mut - Domain sub-client for deployment operations that require mutable client access.
- DevOverlays
Client - Domain sub-client for developer overlay manifest operations.
- Introspection
Client - Domain sub-client for metadata and object introspection operations.
- Provisioning
Client - Domain sub-client for provisioning databases, schemas, and clusters.
- Type
Info Client - Domain sub-client for column/type introspection used by type checking and tests.
- Validation
Client - Domain sub-client for project and privilege validation operations.
Enumsยง
- CaSource ๐
- Where the CA bundle comes from for verifying the server cert, or the absence thereof for non-verifying modes.
- Connector ๐
- Runtime-ready connector variant handed to
tokio_postgres::Config::connect. - Connector
Spec ๐ - Pure-data representation of the TLS setup for a connection, derived from
a profileโs effective
SslModeandsslrootcert.
Constantsยง
- APPLICATION_
NAME ๐
Functionsยง
- build_
connector ๐ - Convert a
ConnectorSpecinto a runtimeConnector. All filesystem I/O for CAs happens here. - build_
options_ ๐string - Build the inner value of the libpq
optionsconnection parameter from a profileโs options map. - classify_
connect_ ๐error - Classify a
tokio_postgres::Errorsurfaced fromConfig::connect(...)into the most specificConnectionErrorvariant. - default_
sslmode ๐ - The default
SslModeapplied when a profile does not setsslmode. - escape_
options_ ๐value - Escape a value for embedding inside the libpq
optionsconnection parameter. - is_
loopback_ ๐host - Returns
trueifhostnames the loopback interface. - matches_
tls_ ๐refused_ message - Pure string check for the substrings
tokio_postgresproduces when the server refuses the TLS startup request (responds'N'to the SSL byte). - message_
indicates_ ๐tls_ refused - Heuristic: does the error look like โserver said no to our TLS requestโ?
- plan_
connector ๐ - Plan the TLS setup for a connection from the resolved (mode, CA) inputs.
- tls_
error_ ๐in_ chain - Walk the source chain of a
tokio_postgres::Errorand return the firstrustls::Errorfound. - tokio_
ssl_ ๐mode