2

我有一个在 gRPC 服务中使用的 Protobuf 文件 Routing.proto。我还有一个 Envoy simple.yaml 文件。我正在尝试在方法 service_B_hello(1) 上进行 gRPC 路由匹配,其中 1 是包含在 CopyImageRequest 中的 camera_id 值。如何在 Envoy 中使用请求中的方法参数 camera_id 进行此路由匹配?

路由.proto:

syntax = "proto3";
package routing;
message CopyImageRequest {
    int32 camera_id = 1;
}
message CopyImageResponse {
    string result = 1;
}
service RoutingService {
    rpc service_A_hello(CopyImageRequest) returns (CopyImageResponse) {};
    rpc service_B_hello(CopyImageRequest) returns (CopyImageResponse) {};
    rpc service_C_hello(CopyImageRequest) returns (CopyImageResponse) {};
}

simple.yaml 特使文件:

routes:
- match:
  prefix:"/routing.RoutingService/service_B_hello"
  headers:
  - name: "method"
    exact_match: "service_B_hello"
  - name: "camera_id"
    regex_match: ^[0-3]$
  - name: content-type
    exact_match: application/grpc            
  grpc: {}
  route:
    auto_host_rewrite: true
    cluster: grpc_stateless_service

TIA,

4

0 回答 0