mz_aws_glue_schema_registry/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#![warn(missing_debug_implementations)]
11
12//! An API client for the [AWS Glue Schema Registry][gsr].
13//!
14//! This crate is the Glue analogue of [`mz-ccsr`], the Confluent Schema
15//! Registry client. It is intentionally narrow: only the surface needed by
16//! the current Materialize integration is implemented.
17//!
18//! Read path (source decode, DDL planning, connection validation):
19//!
20//! * [`Client::get_registry`] — used by `GlueSchemaRegistryConnection::validate`
21//! to verify a registry exists at `CREATE CONNECTION` time.
22//! * [`Client::get_schema_version_by_id`] — source decode: fetch a writer
23//! schema by the UUID embedded in each record's Glue wire-format header.
24//! * [`Client::get_schema_version_latest_by_name`] — DDL planning: pin a
25//! reader schema to the registry's current "latest" version.
26//!
27//! Write path (sink encode):
28//!
29//! * [`Client::get_schema_by_definition`] — reuse an already-registered
30//! definition so a sink restart does not create a duplicate version.
31//! * [`Client::register_schema_version`] — add a new version to an existing
32//! schema.
33//! * [`Client::create_schema`] — create a schema on first publish, setting its
34//! compatibility policy.
35//! * [`Client::get_schema`] — read a schema's compatibility to warn on a
36//! mismatch without overwriting it.
37//!
38//! Glue has no separate get/update-compatibility API: a schema's compatibility
39//! is set once at [`Client::create_schema`] and read back via
40//! [`Client::get_schema`]. This crate deliberately exposes no way to change it,
41//! matching the sink's set-if-unset policy.
42//!
43//! ## Example usage
44//!
45//! ```no_run
46//! # async {
47//! use mz_aws_glue_schema_registry::{Client, ClientConfig};
48//! use aws_types::SdkConfig;
49//!
50//! let sdk_config: SdkConfig = unimplemented!("from AwsConnection::load_sdk_config");
51//! let client = ClientConfig::new(sdk_config).build();
52//! let registry = client.get_registry("my-registry").await?;
53//! # let _ = registry;
54//! # Ok::<_, mz_aws_glue_schema_registry::GetRegistryError>(())
55//! # };
56//! ```
57//!
58//! [gsr]: https://docs.aws.amazon.com/glue/latest/dg/schema-registry.html
59//! [`mz-ccsr`]: https://docs.rs/mz-ccsr
60
61mod client;
62mod config;
63
64pub use client::{
65 Client, Compatibility, CreateSchemaError, DataFormat, GetRegistryError,
66 GetSchemaByDefinitionError, GetSchemaError, GetSchemaVersionError, RegisterSchemaVersionError,
67 RegisteredSchemaVersion, Registry, RegistryLifecycleStatus, Schema, SchemaLifecycleStatus,
68 SchemaVersion, SchemaVersionLifecycleStatus,
69};
70pub use config::ClientConfig;