chitralverma commented on code in PR #4077: URL: https://github.com/apache/arrow-rs/pull/4077#discussion_r1182195434
########## object_store/src/builder.rs: ########## @@ -0,0 +1,301 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. + +//! Implementation of `ObjectStoreBuilder` which allows the creation of object store +//! from provided url and options. +//! +use std::collections::HashMap; +pub use std::str::FromStr; +use url::Url; + +#[cfg(feature = "aws")] +use crate::aws; +#[cfg(feature = "azure")] +use crate::azure; +#[cfg(any(feature = "gcp", feature = "aws", feature = "azure", feature = "http"))] +use crate::client::ClientOptions; +#[cfg(feature = "gcp")] +use crate::gcp; +#[cfg(feature = "http")] +use crate::http; +#[cfg(not(target_arch = "wasm32"))] +use crate::local; + +use crate::{memory, DynObjectStore, Error, Result}; + +#[allow(dead_code)] +#[derive(Debug, Clone)] +/// Creates object store from provided url and options +/// +/// The scheme of the provided url is used to instantiate the store. If the url +/// scheme is cannot be mapped to a store, [`NotImplemented`] is raised. For invalid +/// input, e.g. url with no scheme the default behaviour is to return +/// [`local::LocalFileSystem`]. +/// +/// # Examples +/// ``` +/// # let BUCKET_NAME = "foo"; +/// # let ACCESS_KEY_ID = "foo"; +/// # let SECRET_KEY = "foo"; +/// # use object_store::builder::ObjectStoreBuilder;/// +/// +/// // Instantiate Local FS +/// # let LOCAL_URL = "file:///"; +/// let local = ObjectStoreBuilder::new(LOCAL_URL).build(); +/// +/// // Instantiate S3 +/// # let S3_URL = "s3://foo/"; +/// let s3_opts = +/// vec![ +/// ("AWS_ACCESS_KEY_ID", "abc"), +/// ("AWS_SECRET_ACCESS_KEY", "xyz") +/// ]; +/// let s3 = ObjectStoreBuilder::new(S3_URL).with_store_options(s3_opts).build(); +/// +/// // Instantiate Azure +/// # let AZURE_URL = "az://foo/"; +/// let azure = ObjectStoreBuilder::new(AZURE_URL).with_env_variables(true).build(); +/// +/// // Instantiate GCS +/// # let GCS_URL = "gs://foo/"; +/// let gs_opts = vec![("GOOGLE_SERVICE_ACCOUNT", "/tmp/foo.json")]; +/// let gs = ObjectStoreBuilder::new(AZURE_URL) +/// .with_store_options(gs_opts) +/// .with_env_variables(true) +/// .build(); +/// ``` +pub struct ObjectStoreBuilder { Review Comment: @tustvold Based on your comment I have created a builder pattern for object store. If this looks good, the we can get rid of the `options.rs` I add as it contains duplicate code. Also added better examples :) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
