Skip to main content

Module client

Module client 

Source
Expand description

Database client layer for communicating with a Materialize region.

All interaction with the live database flows through this module. The Client type (defined in connection) holds a tokio_postgres connection and exposes scoped sub-clients that group related operations:

  • introspection — Read-only catalog queries: schema/cluster/object existence checks, dependency lookups, and batch metadata retrieval.
  • provisioning — DDL operations that create or alter databases, schemas, and clusters to match the project definition.
  • deployment_ops — Blue/green deployment lifecycle: staging, hydration monitoring, cutover, and abort.
  • validation — Pre-deployment validation: checks that the target environment matches expected state before applying changes.
  • type_infoSHOW COLUMNS queries used to generate and refresh the types.lock data-contract file.

§Supporting Submodules

  • models — Data structures shared across sub-clients (deployment records, cluster configs, conflict records, etc.).
  • errors — Error types: ConnectionError for transport/query failures, DatabaseValidationError for semantic mismatches.

Most sub-client types are internal; this module re-exports the key public types so that consumers only need use crate::client::*.

Re-exports§

pub use crate::config::Profile;

Structs§

Client
Database client for interacting with Materialize.
Cluster
A compute cluster in Materialize.
ClusterOptions
Options for creating a new cluster.
ClusterReplica
Configuration for a cluster replica (used for unmanaged clusters).
ClusterStatusContext
Full status context for a cluster in a staging deployment.
ConflictRecord
A conflict record indicating a schema was updated after deployment started.
DependentSink
A sink that depends on an object in a schema being dropped.
DeploymentDetails
Details about a specific deployment.
DeploymentHistoryEntry
A promoted deployment in history.
DeploymentMetadata
Metadata about a deployment.
DeploymentObjectRecord
An object deployment record tracking object-level deployment history.
DevOverlaysClient
Domain sub-client for developer overlay manifest operations.
HydrationStatusUpdate
A hydration status update from the SUBSCRIBE stream.
ObjectGrant
A privilege grant on a cluster.
PendingStatement
A pending statement to be executed after the swap.
ProductionClusterRecord
A cluster known to host at least one promoted deployment.
ReplacementMvRecord
A replacement materialized view record tracking the mapping between the replacement MV (in staging schema) and its production target.
SchemaDeploymentRecord
A schema deployment record tracking when and how a schema was deployed.
StagingDeployment
Summary of a staging deployment.

Enums§

ApplyState
State of an apply operation for resumable apply.
ClusterConfig
Configuration for creating a cluster (managed or unmanaged).
ClusterDeploymentStatus
Status of a cluster in a staging deployment.
ConnectionError
Errors that can occur during database operations.
DatabaseValidationError
Errors that can occur during project validation against the database.
DeploymentKind
The type of deployment - either tables-only or full objects.
DeploymentMode
Deployment mode tag stored alongside each deployment.
FailureReason
Reason why a cluster deployment is failing.

Constants§

DEFAULT_ALLOWED_LAG_SECS
Default allowed lag threshold in seconds (5 minutes).
SERVER_CLUSTER_NAME
Name of the dedicated cluster mz-deploy creates during setup and pins every connection to via libpq options.

Functions§

format_relative_path
Extract last 3 path components for display (database/schema/file.sql).
quote_identifier
Double-quote a SQL identifier, escaping any embedded double quotes.
sql_placeholders
Build a comma-separated $1, $2, …, $n placeholder string for parameterized queries.