de.otto.synapse.edison.health.StartupHealthIndicator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of synapse-edison Show documentation
Show all versions of synapse-edison Show documentation
A library used at otto.de to integrate synapse-core with edison-microservice.
The newest version!
package de.otto.synapse.edison.health;
import de.otto.synapse.eventsource.EventSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toSet;
/**
* A Spring Boot HealthIndicator that is healthy after finishing all events of an
* {@link de.otto.synapse.eventsource.EventSource} for the first time.
*
* Caution: If you add eventsources asynchronously please use {@link FixedChannelHealthIndicator} instead.
*/
@Component
@ConditionalOnProperty(
prefix = "synapse.edison.health",
name = "startup.enabled",
havingValue = "true",
matchIfMissing = true)
@ConditionalOnBean(EventSource.class)
public class StartupHealthIndicator extends AbstractChannelHealthIndicator {
@Autowired
public StartupHealthIndicator(final Optional> eventSources) {
super(eventSources.orElse(emptyList())
.stream()
.map(EventSource::getChannelName)
.collect(toSet()));
}
}