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, cargo clippy complains with:
14//     overflow evaluating the requirement `&str: std::marker::Send`
15// in implement_peek_plan's return of a Result<crate::ExecuteResponse, AdapterError>.
16#![recursion_limit = "256"]
17
18//! Coordinates client requests with the dataflow layer.
19//!
20//! This crate hosts the "coordinator", an object which sits at the center of
21//! the system and coordinates communication between the various components.
22//! Responsibilities of the coordinator include:
23//!
24//!   * Launching the dataflow workers.
25//!   * Periodically allowing the dataflow workers to compact existing data.
26//!   * Executing SQL queries from clients by parsing and planning them, sending
27//!     the plans to the dataflow layer, and then streaming the results back to
28//!     the client.
29//!   * Assigning timestamps to incoming source data.
30//!
31//! The main interface to the coordinator is [`Client`]. To start a coordinator,
32//! use the [`serve`] function.
33
34// TODO(benesch): delete this once we use structured errors everywhere.
35macro_rules! coord_bail {
36    ($($e:expr),*) => {
37        return Err(crate::error::AdapterError::Unstructured(::anyhow::anyhow!($($e),*)))
38    }
39}
40
41mod active_compute_sink;
42mod command;
43mod coord;
44mod error;
45mod explain;
46mod frontend_peek;
47mod notice;
48mod optimize;
49mod util;
50
51pub mod catalog;
52pub mod client;
53pub mod config;
54pub mod continual_task;
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::{ExecuteResponse, ExecuteResponseKind, StartupResponse};
67pub use crate::coord::ExecuteContext;
68pub use crate::coord::ExecuteContextExtra;
69pub use crate::coord::id_bundle::CollectionIdBundle;
70pub use crate::coord::peek::PeekResponseUnary;
71pub use crate::coord::read_policy::ReadHolds;
72pub use crate::coord::timeline::TimelineContext;
73pub use crate::coord::timestamp_selection::{
74    TimestampContext, TimestampExplanation, TimestampProvider,
75};
76pub use crate::coord::{Config, load_remote_system_parameters, serve};
77pub use crate::error::AdapterError;
78pub use crate::notice::AdapterNotice;
79pub use crate::util::{ResultExt, verify_datum_desc};
80pub use crate::webhook::{
81    AppendWebhookError, AppendWebhookResponse, AppendWebhookValidator, WebhookAppenderCache,
82};