com.transferwise.envoy.xds.delta.DeltaAggregatedDiscoveryService Maven / Gradle / Ivy
The newest version!
package com.transferwise.envoy.xds.delta;
import com.google.common.collect.ImmutableList;
import com.transferwise.envoy.xds.api.ClusterEventSource;
import com.transferwise.envoy.xds.api.ClientConfigProvider;
import com.transferwise.envoy.xds.CommonDiscoveryRequest;
import com.transferwise.envoy.xds.CommonDiscoveryStreamObserver;
import com.transferwise.envoy.xds.DiscoveryServiceManagerFactory;
import com.transferwise.envoy.xds.api.XdsEventListener;
import com.transferwise.envoy.xds.api.DiscoveryServiceManagerMetrics;
import io.envoyproxy.envoy.service.discovery.v3.DeltaDiscoveryRequest;
import io.envoyproxy.envoy.service.discovery.v3.DeltaDiscoveryResponse;
import io.grpc.stub.StreamObserver;
import java.util.function.Supplier;
public class DeltaAggregatedDiscoveryService {
private final ClusterEventSource clusterManager;
private final DiscoveryServiceManagerFactory discoveryServiceManagerFactory;
private final ClientConfigProvider clientConfigSource;
private final Supplier metricsFactory;
private final ImmutableList> listeners;
public DeltaAggregatedDiscoveryService(ClusterEventSource clusterManager,
DiscoveryServiceManagerFactory discoveryServiceManagerFactory,
ClientConfigProvider clientConfigSource,
ImmutableList> listeners,
Supplier metricsFactory) {
this.clusterManager = clusterManager;
this.discoveryServiceManagerFactory = discoveryServiceManagerFactory;
this.clientConfigSource = clientConfigSource;
this.metricsFactory = metricsFactory;
this.listeners = listeners;
}
public StreamObserver streamDeltaAggregatedResources(StreamObserver responseObserver) {
return new CommonDiscoveryStreamObserver<>(
responseObserver,
clusterManager,
discoveryServiceManagerFactory,
this::convertToCommonDiscoveryRequest,
clientConfigSource,
listeners,
metricsFactory.get()
);
}
private CommonDiscoveryRequest convertToCommonDiscoveryRequest(DeltaDiscoveryRequest request) {
return CommonDiscoveryRequest.builder()
.typeUrl(request.getTypeUrl())
.errorDetail(request.hasErrorDetail() ? request.getErrorDetail() : null)
.node(request.getNode())
.message(request)
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy