Skip to content

chore(volo-http): refactor ClientBuilder, Target and CallOpt#528

Merged
yukiiiteru merged 1 commit intocloudwego:mainfrom
yukiiiteru:chore/client-refactor
Nov 11, 2024
Merged

chore(volo-http): refactor ClientBuilder, Target and CallOpt#528
yukiiiteru merged 1 commit intocloudwego:mainfrom
yukiiiteru:chore/client-refactor

Conversation

@yukiiiteru
Copy link
Copy Markdown
Contributor

This commit refactors ClientBuilder, Target and CallOpt.

ClientBuilder

  • ClientBuilder::caller_name and ClientBuilder::callee_name are renamed to ClientBuilder::user_agent and ClientBuilder::default_host
  • ClientBuilder::build will add some default layers
    • Timeout: Apply current timeout for the request
    • Host: Target::gen_host is removed and Host will not be inserted to request headers by default. This layer can insert it if there is no Host
    • UserAgent: Insert User-Agent to request headers
  • Add ClientBuilder::build_without_extra_layers for create a client without the above layers
  • ClientBuilder related methods will not return Result, error will be recorded and thrown in build or build_without_extra_layers

Target

  • Remove https: bool field, use scheme: Scheme instead
  • Remove TargetParser and parse_target, use volo::client::Apply instead
  • Remove gen_host, use Host layer instead

CallOpt

  • CallOpt uses the same usage as Volo-Thrift, RequestBuilder::with_callopt will create a WithOptService for using it
  • Due to the above reason, it will no longer depend on TargetParser

@yukiiiteru yukiiiteru requested review from a team as code owners November 8, 2024 14:18
PureWhiteWu
PureWhiteWu previously approved these changes Nov 9, 2024
This commit refactors `ClientBuilder`, `Target` and `CallOpt`.

`ClientBuilder`
- `ClientBuilder::caller_name` and `ClientBuilder::callee_name` are
  renamed to `ClientBuilder::user_agent` and
  `ClientBuilder::default_host`
- `ClientBuilder::build` will add some default layers
  - `Timeout`: Apply current timeout for the request
  - `Host`: `Target::gen_host` is removed and `Host` will not be
    inserted to request headers by default. This layer can insert it
    if there is no `Host`
  - `UserAgent`: Insert `User-Agent` to request headers
- Add `ClientBuilder::build_without_extra_layers` for create a client
  without the above layers
- `ClientBuilder` related methods will not return `Result`, error will
  be recorded and thrown in `build` or `build_without_extra_layers`

`Target`
- Remove `https: bool` field, use `scheme: Scheme` instead
- Remove `TargetParser` and `parse_target`, use `volo::client::Apply`
  instead
- Remove `gen_host`, use `Host` layer instead

`CallOpt`
- `CallOpt` uses the same usage as Volo-Thrift,
  `RequestBuilder::with_callopt` will create a `WithOptService` for
  using it
- Due to the above reason, it will no longer depend on `TargetParser`

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
@yukiiiteru yukiiiteru force-pushed the chore/client-refactor branch from 2ae3b5b to e37218f Compare November 11, 2024 08:18
@yukiiiteru yukiiiteru merged commit 9cd838e into cloudwego:main Nov 11, 2024
@yukiiiteru yukiiiteru deleted the chore/client-refactor branch November 11, 2024 09:12
@yukiiiteru yukiiiteru mentioned this pull request Nov 27, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants