Skip to main content

risingwave_connector/schema/
mod.rs

1// Copyright 2023 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use crate::error::ConnectorError;
16
17pub mod avro;
18mod loader;
19pub mod protobuf;
20pub mod pulsar_schema;
21pub mod schema_registry;
22
23pub use loader::{ConfluentSchemaLoader, SchemaLoader, SchemaVersion};
24
25const MESSAGE_NAME_KEY: &str = "message";
26const KEY_MESSAGE_NAME_KEY: &str = "key.message";
27const SCHEMA_LOCATION_KEY: &str = "schema.location";
28const SCHEMA_REGISTRY_KEY: &str = "schema.registry";
29const NAME_STRATEGY_KEY: &str = "schema.registry.name.strategy";
30pub const AWS_GLUE_SCHEMA_ARN_KEY: &str = "aws.glue.schema_arn";
31
32#[derive(Debug, thiserror::Error, thiserror_ext::Macro)]
33#[error("Invalid option: {message}")]
34pub struct InvalidOptionError {
35    pub message: String,
36    // #[backtrace]
37    // source: Option<risingwave_common::error::BoxedError>,
38}
39
40#[derive(Debug, thiserror::Error, thiserror_ext::Macro)]
41#[error("Malformed response: {message}")]
42pub struct MalformedResponseError {
43    pub message: String,
44}
45
46#[derive(Debug, thiserror::Error)]
47pub enum SchemaFetchError {
48    #[error(transparent)]
49    InvalidOption(#[from] InvalidOptionError),
50    #[error(transparent)]
51    License(#[from] risingwave_common::license::FeatureNotAvailable),
52    #[error(transparent)]
53    Request(#[from] schema_registry::ConcurrentRequestError),
54    #[error(transparent)]
55    AwsGlue(#[from] Box<aws_sdk_glue::operation::get_schema_version::GetSchemaVersionError>),
56    #[error(transparent)]
57    MalformedResponse(#[from] MalformedResponseError),
58    #[error("schema version id invalid: {0}")]
59    InvalidUuid(#[from] uuid::Error),
60    #[error("schema compilation error: {0}")]
61    SchemaCompile(
62        #[source]
63        #[backtrace]
64        risingwave_common::error::BoxedError,
65    ),
66    #[error("{0}")] // source+{0} is effectively transparent but allows backtrace
67    YetToMigrate(
68        #[source]
69        #[backtrace]
70        ConnectorError,
71    ),
72    #[error("schema registry client error: {0}")]
73    Client(#[from] schema_registry::SchemaRegistryClientError),
74}