Search in sources :

Example 1 with CustomClusterType

use of io.envoyproxy.envoy.config.cluster.v3.Cluster.CustomClusterType in project grpc-java by grpc.

the class ClientXdsClient method parseAggregateCluster.

private static StructOrError<CdsUpdate.Builder> parseAggregateCluster(Cluster cluster) {
    String clusterName = cluster.getName();
    CustomClusterType customType = cluster.getClusterType();
    String typeName = customType.getName();
    if (!typeName.equals(AGGREGATE_CLUSTER_TYPE_NAME)) {
        return StructOrError.fromError("Cluster " + clusterName + ": unsupported custom cluster type: " + typeName);
    }
    io.envoyproxy.envoy.extensions.clusters.aggregate.v3.ClusterConfig clusterConfig;
    try {
        clusterConfig = unpackCompatibleType(customType.getTypedConfig(), io.envoyproxy.envoy.extensions.clusters.aggregate.v3.ClusterConfig.class, TYPE_URL_CLUSTER_CONFIG, TYPE_URL_CLUSTER_CONFIG_V2);
    } catch (InvalidProtocolBufferException e) {
        return StructOrError.fromError("Cluster " + clusterName + ": malformed ClusterConfig: " + e);
    }
    return StructOrError.fromStruct(CdsUpdate.forAggregate(clusterName, clusterConfig.getClustersList()));
}
Also used : CustomClusterType(io.envoyproxy.envoy.config.cluster.v3.Cluster.CustomClusterType) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 CustomClusterType (io.envoyproxy.envoy.config.cluster.v3.Cluster.CustomClusterType)1