Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idea(catalog/rest): Separate static and dynamic props #430

Closed
Xuanwo opened this issue Jul 3, 2024 · 5 comments · Fixed by #431
Closed

idea(catalog/rest): Separate static and dynamic props #430

Xuanwo opened this issue Jul 3, 2024 · 5 comments · Fixed by #431

Comments

@Xuanwo
Copy link
Member

Xuanwo commented Jul 3, 2024

Current reset catalog's init logic doesn't look good:

pub async fn new(config: RestCatalogConfig) -> Result<Self> {
    let mut catalog = Self {
        client: config.try_create_rest_client()?,
        config,
    };
    catalog.fetch_access_token().await?;
    catalog.client = catalog.config.try_create_rest_client()?;
    catalog.update_config().await?;
    catalog.client = catalog.config.try_create_rest_client()?;

    Ok(catalog)
}

We need to:

  • create a new http client (with self.config)
  • fetch_access_token (self.config.props changed)
  • create a new http client (with the new self.config)
  • update_config (self.config.props changed)
  • create a new http client (with the new self.config)

I suggest separating static and dynamic properties. Keep the configuration and HTTP client static, unchanged. Store dynamic properties separately and merge them only when sending a request. This approach could also help resolve issue #422.

@liurenjie1024
Copy link
Contributor

The problem is that the first update_config may return things that may change behavior of rest client, for example headers, or relocated url, IIRC.

@Xuanwo
Copy link
Member Author

Xuanwo commented Jul 3, 2024

Got it. I have a better idea, let's discuss on the PR.

@TennyZhuang
Copy link
Contributor

BTW should we use a strong-typed Config/Props instead of a Hashmap? Do we have discussions before?

@Xuanwo
Copy link
Member Author

Xuanwo commented Jul 3, 2024

BTW should we use a strong-typed Config/Props instead of a Hashmap? Do we have discussions before?

I like this idea. Please feel free to start a discussion about it. Actually, I'm not sure how many valid options are available in the props.

@liurenjie1024
Copy link
Contributor

BTW should we use a strong-typed Config/Props instead of a Hashmap? Do we have discussions before?

It seems that there is no clear definition of all props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants