diff --git a/src/connector/codec/src/common/mod.rs b/src/connector/codec/src/common/mod.rs new file mode 100644 index 000000000000..c8a7ca35c420 --- /dev/null +++ b/src/connector/codec/src/common/mod.rs @@ -0,0 +1,15 @@ +// Copyright 2024 RisingWave Labs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +pub mod protobuf; diff --git a/src/connector/codec/src/decoder/protobuf/compiler.rs b/src/connector/codec/src/common/protobuf/compiler.rs similarity index 100% rename from src/connector/codec/src/decoder/protobuf/compiler.rs rename to src/connector/codec/src/common/protobuf/compiler.rs diff --git a/src/connector/codec/src/common/protobuf/mod.rs b/src/connector/codec/src/common/protobuf/mod.rs new file mode 100644 index 000000000000..f630dedf0d24 --- /dev/null +++ b/src/connector/codec/src/common/protobuf/mod.rs @@ -0,0 +1,16 @@ +// Copyright 2024 RisingWave Labs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +mod compiler; +pub use compiler::compile_pb; diff --git a/src/connector/codec/src/decoder/protobuf/mod.rs b/src/connector/codec/src/decoder/protobuf/mod.rs index 5f17ccaf5588..7ad357fef50f 100644 --- a/src/connector/codec/src/decoder/protobuf/mod.rs +++ b/src/connector/codec/src/decoder/protobuf/mod.rs @@ -12,12 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -mod compiler; pub mod parser; use std::borrow::Cow; use std::sync::LazyLock; -pub use compiler::compile_pb; use parser::from_protobuf_value; use prost_reflect::{DynamicMessage, ReflectMessage}; use risingwave_common::log::LogSuppresser; diff --git a/src/connector/codec/src/lib.rs b/src/connector/codec/src/lib.rs index 2119c1ece4e5..d3f0a8c6ec2c 100644 --- a/src/connector/codec/src/lib.rs +++ b/src/connector/codec/src/lib.rs @@ -37,6 +37,7 @@ #![register_tool(rw)] #![recursion_limit = "256"] +pub mod common; /// Converts JSON/AVRO/Protobuf data to RisingWave datum. /// The core API is [`decoder::Access`]. pub mod decoder; diff --git a/src/connector/codec/tests/integration_tests/main.rs b/src/connector/codec/tests/integration_tests/main.rs index f64720aca5db..010fe0593651 100644 --- a/src/connector/codec/tests/integration_tests/main.rs +++ b/src/connector/codec/tests/integration_tests/main.rs @@ -23,7 +23,7 @@ //! ## Why not directly test the uppermost layer `AvroParserConfig` and `AvroAccessBuilder`? //! //! Because their interface are not clean enough, and have complex logic like schema registry. -//! We might need to separate logic to make them clenaer and then we can use it directly for testing. +//! We might need to separate logic to make them cleaner and then we can use it directly for testing. //! //! ## If we reimplement a similar logic here, what are we testing? //! diff --git a/src/connector/codec/tests/integration_tests/protobuf.rs b/src/connector/codec/tests/integration_tests/protobuf.rs index 5fef063f6206..b07d5f739b81 100644 --- a/src/connector/codec/tests/integration_tests/protobuf.rs +++ b/src/connector/codec/tests/integration_tests/protobuf.rs @@ -23,8 +23,9 @@ use std::path::PathBuf; use anyhow::Context; use prost::Message; use prost_reflect::{DescriptorPool, DynamicMessage, MessageDescriptor}; +use risingwave_connector_codec::common::protobuf::compile_pb; use risingwave_connector_codec::decoder::protobuf::parser::*; -use risingwave_connector_codec::decoder::protobuf::{compile_pb, ProtobufAccess}; +use risingwave_connector_codec::decoder::protobuf::ProtobufAccess; use risingwave_connector_codec::decoder::Access; use thiserror_ext::AsReport; diff --git a/src/connector/src/schema/protobuf.rs b/src/connector/src/schema/protobuf.rs index e792427d90eb..634d692066ac 100644 --- a/src/connector/src/schema/protobuf.rs +++ b/src/connector/src/schema/protobuf.rs @@ -16,7 +16,7 @@ use std::collections::BTreeMap; use std::path::PathBuf; use prost_reflect::{DescriptorPool, FileDescriptor, MessageDescriptor}; -use risingwave_connector_codec::decoder::protobuf::compile_pb; +use risingwave_connector_codec::common::protobuf::compile_pb; use super::loader::{LoadedSchema, SchemaLoader}; use super::schema_registry::Subject;