chore(volo-http): refactor ClientBuilder, Target and CallOpt#528
Merged
yukiiiteru merged 1 commit intocloudwego:mainfrom Nov 11, 2024
Merged
chore(volo-http): refactor ClientBuilder, Target and CallOpt#528yukiiiteru merged 1 commit intocloudwego:mainfrom
ClientBuilder, Target and CallOpt#528yukiiiteru merged 1 commit intocloudwego:mainfrom
Conversation
PureWhiteWu
previously approved these changes
Nov 9, 2024
75b770b to
2ae3b5b
Compare
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>
2ae3b5b to
e37218f
Compare
PureWhiteWu
approved these changes
Nov 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit refactors
ClientBuilder,TargetandCallOpt.ClientBuilderClientBuilder::caller_nameandClientBuilder::callee_nameare renamed toClientBuilder::user_agentandClientBuilder::default_hostClientBuilder::buildwill add some default layersTimeout: Apply current timeout for the requestHost:Target::gen_hostis removed andHostwill not be inserted to request headers by default. This layer can insert it if there is noHostUserAgent: InsertUser-Agentto request headersClientBuilder::build_without_extra_layersfor create a client without the above layersClientBuilderrelated methods will not returnResult, error will be recorded and thrown inbuildorbuild_without_extra_layersTargethttps: boolfield, usescheme: SchemeinsteadTargetParserandparse_target, usevolo::client::Applyinsteadgen_host, useHostlayer insteadCallOptCallOptuses the same usage as Volo-Thrift,RequestBuilder::with_calloptwill create aWithOptServicefor using itTargetParser