cloudwego / volo

Rust RPC framework with high-performance and strong-extensibility for building micro-services.
https://crates.io/crates/volo
Apache License 2.0
2.21k stars 181 forks source link

chore(volo-http): refactor Target of discover for more scalability #435

Closed yukiiiteru closed 4 months ago

yukiiiteru commented 4 months ago

Motivation

431 has refactored service discover and treat DNS resolver as a service discover for HTTP client, but the previous implementation does not have strong scalability, for example, the Target is designed for DNS resolver only.

Solution

This PR refactored the Target and added TypeMap and FastStrMap for it. In addition, a new param target_parser is also added.

For resolving an address, the conversion path is:

  1. Parse str to Uri and build a Target from the Uri
  2. Call the target_parser so that it can resolve the Target and set necessary information to Endpoint
  3. The service discover will resolve Endpoint to Address
  4. Access it.

Fixes: #431