Skip to content

Commit

Permalink
support creating client with configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
zuston committed Jan 4, 2024
1 parent ede9537 commit 4fb8b93
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rust/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ impl Client {
Self::with_config(&parsed_url, Configuration::new()?)
}

pub fn new_with_config(url: &str, configuration: Configuration) -> Result<Self> {
let parsed_url = Url::parse(url)?;
Self::with_config(&parsed_url, configuration)
}

fn with_config(url: &Url, config: Configuration) -> Result<Self> {
if !url.has_host() {
return Err(HdfsError::InvalidArgument(
Expand Down
8 changes: 8 additions & 0 deletions rust/src/common/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ pub struct Configuration {
map: HashMap<String, String>,
}

impl From<HashMap<String, String>> for Configuration {
fn from(conf_map: HashMap<String, String>) -> Self {
Self {
map: conf_map,
}
}
}

impl Configuration {
pub fn new() -> io::Result<Self> {
let mut map: HashMap<String, String> = HashMap::new();
Expand Down

0 comments on commit 4fb8b93

Please sign in to comment.