envoy-filter-example

最近学习开发envoy扩展,希望给envoy加一些功能,但是出现一个错误

https://github.com/envoyproxy/envoy-filter-example/blob/main/echo2_server.yaml

Didn't find a registered implementation for 'echo2' with type URL: ''

Envoy 官网的测试yaml文件:

admin:
  access_log_path: /dev/null
  address:
    socket_address:
      address: 127.0.0.1
      port_value: 0
static_resources:
  clusters:
    name: cluster_0
    connect_timeout: 0.25s
    load_assignment:
      cluster_name: cluster_0
      endpoints:
        - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: 127.0.0.1
                    port_value: 0
  listeners:
    name: listener_0
    address:
      socket_address:
        address: 127.0.0.1
        port_value: 0
    filter_chains:
    - filters:
      - name: echo2
        typed_config:

由于envoy的不断迭代,估计envoy-filter-example的更新迭代并没有跟上,于是出现了这个错误

查看echo2_config.cc关键代码:

  ProtobufTypes::MessagePtr createEmptyConfigProto() override {
    auto ptr = ProtobufTypes::MessagePtr{new Envoy::ProtobufWkt::Struct()};
    std::cout << "full_name:" << ptr->GetDescriptor()->full_name() << std::endl;
    return ptr;
  }

打印结果:

full_name:google.protobuf.Struct

修改官网测试yaml文件:

admin:
  access_log_path: /dev/null
  address:
    socket_address:
      address: 127.0.0.1
      port_value: 0
static_resources:
  clusters:
    name: cluster_0
    connect_timeout: 0.25s
    load_assignment:
      cluster_name: cluster_0
      endpoints:
        - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: 127.0.0.1
                    port_value: 0
  listeners:
    name: listener_0
    address:
      socket_address:
        address: 127.0.0.1
        port_value: 8080
    filter_chains:
    - filters:
      - name: echo2
        typed_config:
          "@type": type.googleapis.com/google.protobuf.Struct

 二进制程序运行正常

你可能感兴趣的:(服务器,网络,linux)