io.cereebro.snitch.detect.eureka.EurekaServerRelationshipDetector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cereebro-snitch Show documentation
Show all versions of cereebro-snitch Show documentation
Cereebro Snitch Spring Boot AutoConfiguration
/*
* Copyright © 2017 the original authors (http://cereebro.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cereebro.snitch.detect.eureka;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.util.CollectionUtils;
import com.netflix.discovery.EurekaClient;
import io.cereebro.core.Component;
import io.cereebro.core.ComponentType;
import io.cereebro.core.Dependency;
import io.cereebro.core.Relationship;
import io.cereebro.core.RelationshipDetector;
/**
* Eureka Server relationship detector. If some {@link EurekaClient} bean is
* available in the context, we'll just create one relationship to a Eureka
* Server component with a default name.
*
* @author michaeltecourt
*
*/
public class EurekaServerRelationshipDetector implements RelationshipDetector {
static final String DEFAULT_NAME = "eureka-server";
private final List eurekaClients;
/**
* Eureka Server relationship detector.
*
* @param eurekaClients
* Eureka Client instances available (nullable).
*/
public EurekaServerRelationshipDetector(List eurekaClients) {
this.eurekaClients = new ArrayList<>();
if (!CollectionUtils.isEmpty(eurekaClients)) {
this.eurekaClients.addAll(eurekaClients);
}
}
@Override
public Set detect() {
if (eurekaClients.isEmpty()) {
return new HashSet<>();
}
return Dependency.on(Component.of(DEFAULT_NAME, ComponentType.HTTP_APPLICATION_REGISTRY)).asRelationshipSet();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy