Skip to main content

mz_adapter/
lib.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10// Disallow usage of `unwrap()`.
11#![warn(clippy::unwrap_used)]
12#![cfg_attr(nightly_doc_features, feature(doc_cfg))]
13// Without this, rustc overflows its query depth when computing the layout of deeply nested async
14// fn bodies, e.g. `Coordinator::catalog_transact_with_side_effects`.
15#![recursion_limit = "256"]
16
17//! Coordinates client requests with the dataflow layer.
18//!
19//! This crate hosts the "coordinator", an object which sits at the center of
20//! the system and coordinates communication between the various components.
21//! Responsibilities of the coordinator include:
22//!
23//!   * Launching the dataflow workers.
24//!   * Periodically allowing the dataflow workers to compact existing data.
25//!   * Executing SQL queries from clients by parsing and planning them, sending
26//!     the plans to the dataflow layer, and then streaming the results back to
27//!     the client.
28//!   * Assigning timestamps to incoming source data.
29//!
30//! The main interface to the coordinator is [`Client`]. To start a coordinator,
31//! use the [`serve`] function.
32
33// TODO(benesch): delete this once we use structured errors everywhere.
34macro_rules! coord_bail {
35    ($($e:expr),*) => {
36        return Err(crate::error::AdapterError::Unstructured(::anyhow::anyhow!($($e),*)))
37    }
38}
39
40mod active_compute_sink;
41mod command;
42mod coord;
43mod error;
44mod explain;
45mod frontend_read_then_write;
46mod frontend_transaction;
47mod notice;
48mod optimize;
49mod peek_sequencing;
50mod util;
51
52pub mod catalog;
53pub mod client;
54pub mod config;
55pub mod flags;
56pub mod metrics;
57pub mod peek_client;
58pub mod session;
59pub mod statement_logging;
60pub mod telemetry;
61pub mod webhook;
62
63pub use crate::peek_client::PeekClient;
64
65pub use crate::client::{Client, Handle, SessionClient};
66pub use crate::command::{
67    CopyFromStdinWriter, ExecuteResponse, ExecuteResponseKind, StartupResponse,
68};
69pub use crate::coord::ExecuteContext;
70pub use crate::coord::ExecuteContextExtra;
71pub use crate::coord::ExecuteContextGuard;
72pub use crate::coord::id_bundle::CollectionIdBundle;
73pub use crate::coord::peek::PeekResponseUnary;
74pub use crate::coord::read_policy::ReadHolds;
75pub use crate::coord::timeline::TimelineContext;
76pub use crate::coord::timestamp_selection::{
77    TimestampContext, TimestampExplanation, TimestampProvider,
78};
79pub use crate::coord::{Config, RemoteSystemParameters, load_remote_system_parameters, serve};
80pub use crate::error::{AdapterError, AuthenticationError};
81pub use crate::notice::{AdapterNotice, ExecutionTime};
82pub use crate::util::{ResultExt, verify_datum_desc};
83pub use crate::webhook::{
84    AppendWebhookError, AppendWebhookResponse, AppendWebhookValidator, WebhookAppenderCache,
85};