/** * Create a {@link CompositeReactiveHealthIndicator} based on the specified health * indicators. Each {@link HealthIndicator} are wrapped to a * {@link HealthIndicatorReactiveAdapter}. If two instances share the same name, the * reactive variant takes precedence. * @param healthAggregator the {@link HealthAggregator} * @param reactiveHealthIndicators the {@link ReactiveHealthIndicator} instances * mapped by name * @param healthIndicators the {@link HealthIndicator} instances mapped by name if * any. * @return a {@link ReactiveHealthIndicator} that delegates to the specified * {@code reactiveHealthIndicators}. */ public CompositeReactiveHealthIndicator createReactiveHealthIndicator( HealthAggregator healthAggregator, Map<String, ReactiveHealthIndicator> reactiveHealthIndicators, Map<String, HealthIndicator> healthIndicators) { Assert.notNull(healthAggregator, "HealthAggregator must not be null"); Assert.notNull(reactiveHealthIndicators, "ReactiveHealthIndicators must not be null"); ReactiveHealthIndicatorRegistryFactory factory = new ReactiveHealthIndicatorRegistryFactory( this.healthIndicatorNameFactory); return new CompositeReactiveHealthIndicator(healthAggregator, factory.createReactiveHealthIndicatorRegistry(reactiveHealthIndicators, healthIndicators)); }
/** * Create a {@link ReactiveHealthIndicatorRegistry} based on the specified health * indicators. Each {@link HealthIndicator} are wrapped to a * {@link HealthIndicatorReactiveAdapter}. If two instances share the same name, the * reactive variant takes precedence. * @param reactiveHealthIndicators the {@link ReactiveHealthIndicator} instances * mapped by name * @param healthIndicators the {@link HealthIndicator} instances mapped by name if * any. * @return a {@link ReactiveHealthIndicator} that delegates to the specified * {@code reactiveHealthIndicators}. */ public ReactiveHealthIndicatorRegistry createReactiveHealthIndicatorRegistry( Map<String, ReactiveHealthIndicator> reactiveHealthIndicators, Map<String, HealthIndicator> healthIndicators) { Assert.notNull(reactiveHealthIndicators, "ReactiveHealthIndicators must not be null"); return initialize(new DefaultReactiveHealthIndicatorRegistry(), reactiveHealthIndicators, healthIndicators); }
protected <T extends ReactiveHealthIndicatorRegistry> T initialize(T registry, Map<String, ReactiveHealthIndicator> reactiveHealthIndicators, Map<String, HealthIndicator> healthIndicators) { merge(reactiveHealthIndicators, healthIndicators) .forEach((beanName, indicator) -> { String name = this.healthIndicatorNameFactory.apply(beanName); registry.register(name, indicator); }); return registry; }
@Bean @ConditionalOnMissingBean public ReactiveHealthIndicatorRegistry reactiveHealthIndicatorRegistry( ObjectProvider<Map<String, ReactiveHealthIndicator>> reactiveHealthIndicators, ObjectProvider<Map<String, HealthIndicator>> healthIndicators) { return new ReactiveHealthIndicatorRegistryFactory() .createReactiveHealthIndicatorRegistry( reactiveHealthIndicators .getIfAvailable(Collections::emptyMap), healthIndicators.getIfAvailable(Collections::emptyMap)); }