risingwave_connector/source/filesystem/s3/
mod.rs

1// Copyright 2025 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.
14pub mod enumerator;
15
16use phf::{Set, phf_set};
17use serde::Deserialize;
18
19use crate::enforce_secret::EnforceSecret;
20use crate::source::SourceProperties;
21use crate::source::filesystem::file_common::CompressionFormat;
22use crate::source::util::dummy::{
23    DummyProperties, DummySourceReader, DummySplit, DummySplitEnumerator,
24};
25
26/// Refer to [`crate::source::OPENDAL_S3_CONNECTOR`].
27pub const LEGACY_S3_CONNECTOR: &str = "s3";
28
29/// These are supported by both `s3` and `s3_v2` (opendal) sources.
30#[derive(Clone, Debug, Deserialize, PartialEq, with_options::WithOptions)]
31pub struct S3PropertiesCommon {
32    #[serde(rename = "s3.region_name")]
33    pub region_name: String,
34    #[serde(rename = "s3.bucket_name")]
35    pub bucket_name: String,
36    #[serde(rename = "match_pattern", default)]
37    pub match_pattern: Option<String>,
38    #[serde(rename = "s3.credentials.access", default)]
39    pub access: Option<String>,
40    #[serde(rename = "s3.credentials.secret", default)]
41    pub secret: Option<String>,
42    #[serde(rename = "s3.endpoint_url")]
43    pub endpoint_url: Option<String>,
44    #[serde(rename = "compression_format", default = "Default::default")]
45    pub compression_format: CompressionFormat,
46}
47
48impl EnforceSecret for S3PropertiesCommon {
49    const ENFORCE_SECRET_PROPERTIES: Set<&'static str> = phf_set! {
50        "s3.credentials.access",
51        "s3.credentials.secret",
52    };
53}
54
55#[derive(Debug, Clone, PartialEq)]
56pub struct LegacyS3;
57
58/// Note: legacy s3 source is fully deprecated since v2.4.0.
59/// The properties and enumerator are kept, so that meta can start normally.
60pub type LegacyS3Properties = DummyProperties<LegacyS3>;
61
62/// Note: legacy s3 source is fully deprecated since v2.4.0.
63/// The properties and enumerator are kept, so that meta can start normally.
64pub type LegacyS3SplitEnumerator = DummySplitEnumerator<LegacyS3>;
65
66pub type LegacyFsSplit = DummySplit<LegacyS3>;
67
68impl SourceProperties for LegacyS3Properties {
69    type Split = LegacyFsSplit;
70    type SplitEnumerator = LegacyS3SplitEnumerator;
71    type SplitReader = DummySourceReader<LegacyS3>;
72
73    const SOURCE_NAME: &'static str = LEGACY_S3_CONNECTOR;
74}