de.otto.edison.status.indicator.CachedApplicationStatusAggregator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edison-status Show documentation
Show all versions of edison-status Show documentation
Status library of the edison-microservice project.
package de.otto.edison.status.indicator;
import de.otto.edison.status.domain.*;
import javax.annotation.PostConstruct;
import java.util.List;
import static de.otto.edison.status.domain.ApplicationStatus.applicationStatus;
import static java.util.stream.Collectors.toList;
/**
* A caching ApplicationStatusAggregator.
*
* @author Guido Steinacker
* @since 13.02.15
*/
public class CachedApplicationStatusAggregator implements ApplicationStatusAggregator {
private volatile ApplicationStatus cachedStatus;
private final ApplicationInfo applicationInfo;
private final SystemInfo systemInfo;
private final VersionInfo versionInfo;
private final TeamInfo teamInfo;
private final List indicators;
private final List serviceSpecs;
public CachedApplicationStatusAggregator(final ApplicationInfo applicationInfo,
final SystemInfo systemInfo,
final VersionInfo versionInfo,
final TeamInfo teamInfo,
final List indicators,
final List serviceSpecs) {
this.applicationInfo = applicationInfo;
this.systemInfo = systemInfo;
this.versionInfo = versionInfo;
this.teamInfo = teamInfo;
this.indicators = indicators;
this.serviceSpecs = serviceSpecs;
}
@PostConstruct
public void postConstruct() {
update();
}
@Override
public ApplicationStatus aggregatedStatus() {
return cachedStatus;
}
@Override
public void update() {
this.cachedStatus = applicationStatus(applicationInfo, systemInfo, versionInfo, teamInfo, getStatusDetails(indicators), serviceSpecs);
}
private static List getStatusDetails(final List indicators) {
return indicators
.stream()
.flatMap(i->i.statusDetails().stream())
.collect(toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy