com.transferwise.envoy.xds.AggregatedDiscoveryService Maven / Gradle / Ivy
package com.transferwise.envoy.xds;
import com.google.common.collect.ImmutableList;
import com.transferwise.envoy.xds.api.ClientConfigProvider;
import com.transferwise.envoy.xds.api.ClusterEventSource;
import com.transferwise.envoy.xds.api.IncrementalConfigBuilder;
import com.transferwise.envoy.xds.api.StateBacklogFactory;
import com.transferwise.envoy.xds.api.XdsEventListener;
import com.transferwise.envoy.xds.delta.DeltaAggregatedDiscoveryService;
import com.transferwise.envoy.xds.delta.IncrementalDiscoveryServiceFactory;
import com.transferwise.envoy.xds.sotw.SotwAggregatedDiscoveryService;
import com.transferwise.envoy.xds.sotw.SotwDiscoveryServiceFactory;
import com.transferwise.envoy.xds.api.DiscoveryServiceManagerMetrics;
import io.envoyproxy.envoy.service.discovery.v3.AggregatedDiscoveryServiceGrpc;
import io.envoyproxy.envoy.service.discovery.v3.DeltaDiscoveryRequest;
import io.envoyproxy.envoy.service.discovery.v3.DeltaDiscoveryResponse;
import io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest;
import io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse;
import io.grpc.stub.StreamObserver;
import java.util.List;
import java.util.function.Supplier;
public class AggregatedDiscoveryService extends AggregatedDiscoveryServiceGrpc.AggregatedDiscoveryServiceImplBase {
private final SotwAggregatedDiscoveryService sotwAds;
private final DeltaAggregatedDiscoveryService incrementalAds;
public AggregatedDiscoveryService(SotwAggregatedDiscoveryService sotwAds, DeltaAggregatedDiscoveryService incrementalAds) {
this.sotwAds = sotwAds;
this.incrementalAds = incrementalAds;
}
public AggregatedDiscoveryService(
ClusterEventSource clusterManager,
ImmutableList> configBuilders,
ClientConfigProvider clientConfigSource,
ImmutableList> listeners,
StateBacklogFactory stateBacklogFactory,
Supplier metricsFactory
) {
this(
sotwAggregatedDiscoveryService(clusterManager, configBuilders, clientConfigSource, listeners, stateBacklogFactory, metricsFactory),
deltaAggregatedDiscoveryService(clusterManager, configBuilders, clientConfigSource, listeners, stateBacklogFactory, metricsFactory)
);
}
@Override
public StreamObserver streamAggregatedResources(StreamObserver responseObserver) {
return sotwAds.streamAggregatedResources(responseObserver);
}
@Override
public StreamObserver deltaAggregatedResources(StreamObserver responseObserver) {
return incrementalAds.streamDeltaAggregatedResources(responseObserver);
}
public static SotwAggregatedDiscoveryService sotwAggregatedDiscoveryService(
ClusterEventSource clusterManager,
ImmutableList> configBuilders,
ClientConfigProvider clientConfigSource,
ImmutableList> listeners,
StateBacklogFactory stateBacklogFactory,
Supplier metricsFactory
) {
var discoveryServiceManagerFactory = new DiscoveryServiceManagerFactory<>(new SotwDiscoveryServiceFactory<>(configBuilders), stateBacklogFactory);
return new SotwAggregatedDiscoveryService<>(clusterManager, discoveryServiceManagerFactory, clientConfigSource, listeners, metricsFactory);
}
public static DeltaAggregatedDiscoveryService deltaAggregatedDiscoveryService(
ClusterEventSource clusterManager,
List> configBuilders,
ClientConfigProvider clientConfigSource,
ImmutableList> listeners,
StateBacklogFactory stateBacklogFactory,
Supplier metricsFactory
) {
var discoveryServiceManagerFactory = new DiscoveryServiceManagerFactory<>(new IncrementalDiscoveryServiceFactory<>(configBuilders), stateBacklogFactory);
return new DeltaAggregatedDiscoveryService<>(clusterManager, discoveryServiceManagerFactory, clientConfigSource, listeners, metricsFactory);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy