@Test public void testBulkHeadRegistry() { io.github.resilience4j.common.bulkhead.configuration.BulkheadConfigurationProperties.InstanceProperties instanceProperties1 = new io.github.resilience4j.common.bulkhead.configuration.BulkheadConfigurationProperties.InstanceProperties(); instanceProperties1.setMaxConcurrentCalls(3); assertThat(instanceProperties1.getEventConsumerBufferSize()).isNull(); io.github.resilience4j.common.bulkhead.configuration.BulkheadConfigurationProperties.InstanceProperties instanceProperties2 = new io.github.resilience4j.common.bulkhead.configuration.BulkheadConfigurationProperties.InstanceProperties(); instanceProperties2.setMaxConcurrentCalls(2); assertThat(instanceProperties2.getEventConsumerBufferSize()).isNull(); BulkheadConfigurationProperties bulkheadConfigurationProperties = new BulkheadConfigurationProperties(); bulkheadConfigurationProperties.getInstances().put("backend1", instanceProperties1); bulkheadConfigurationProperties.getInstances().put("backend2", instanceProperties2); BulkheadConfiguration bulkheadConfiguration = new BulkheadConfiguration(); DefaultEventConsumerRegistry<BulkheadEvent> eventConsumerRegistry = new DefaultEventConsumerRegistry<>(); BulkheadRegistry bulkheadRegistry = bulkheadConfiguration .bulkheadRegistry(bulkheadConfigurationProperties, eventConsumerRegistry, new CompositeRegistryEventConsumer<>(emptyList()), new CompositeCustomizer<>( Collections.emptyList())); assertThat(bulkheadRegistry.getAllBulkheads().size()).isEqualTo(2); Bulkhead bulkhead1 = bulkheadRegistry.bulkhead("backend1"); assertThat(bulkhead1).isNotNull(); assertThat(bulkhead1.getBulkheadConfig().getMaxConcurrentCalls()).isEqualTo(3); Bulkhead bulkhead2 = bulkheadRegistry.bulkhead("backend2"); assertThat(bulkhead2).isNotNull(); assertThat(bulkhead2.getBulkheadConfig().getMaxConcurrentCalls()).isEqualTo(2); assertThat(eventConsumerRegistry.getAllEventConsumer()).hasSize(2); }
@Bean public BulkheadRegistry bulkheadRegistry( BulkheadConfigurationProperties bulkheadConfigurationProperties, EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry, RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer, @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer) { BulkheadRegistry bulkheadRegistry = createBulkheadRegistry(bulkheadConfigurationProperties, bulkheadRegistryEventConsumer, compositeBulkheadCustomizer); registerEventConsumer(bulkheadRegistry, bulkheadEventConsumerRegistry, bulkheadConfigurationProperties); bulkheadConfigurationProperties.getInstances().forEach((name, properties) -> bulkheadRegistry .bulkhead(name, bulkheadConfigurationProperties .createBulkheadConfig(properties, compositeBulkheadCustomizer, name))); return bulkheadRegistry; }
BulkheadConfiguration { @Bean public BulkheadRegistry bulkheadRegistry( BulkheadConfigurationProperties bulkheadConfigurationProperties, EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry, RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer, @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer) { BulkheadRegistry bulkheadRegistry = createBulkheadRegistry(bulkheadConfigurationProperties, bulkheadRegistryEventConsumer, compositeBulkheadCustomizer); registerEventConsumer(bulkheadRegistry, bulkheadEventConsumerRegistry, bulkheadConfigurationProperties); bulkheadConfigurationProperties.getInstances().forEach((name, properties) -> bulkheadRegistry .bulkhead(name, bulkheadConfigurationProperties .createBulkheadConfig(properties, compositeBulkheadCustomizer, name))); return bulkheadRegistry; } }
BulkheadConfiguration { @Bean public BulkheadRegistry bulkheadRegistry( BulkheadConfigurationProperties bulkheadConfigurationProperties, EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry, RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer, @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer) { BulkheadRegistry bulkheadRegistry = createBulkheadRegistry(bulkheadConfigurationProperties, bulkheadRegistryEventConsumer, compositeBulkheadCustomizer); registerEventConsumer(bulkheadRegistry, bulkheadEventConsumerRegistry, bulkheadConfigurationProperties); bulkheadConfigurationProperties.getInstances().forEach((name, properties) -> bulkheadRegistry .bulkhead(name, bulkheadConfigurationProperties .createBulkheadConfig(properties, compositeBulkheadCustomizer, name))); return bulkheadRegistry; }  }
BulkheadConfiguration { @Bean public BulkheadRegistry bulkheadRegistry( BulkheadConfigurationProperties bulkheadConfigurationProperties, EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry, RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer, @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer) { BulkheadRegistry bulkheadRegistry = createBulkheadRegistry(bulkheadConfigurationProperties, bulkheadRegistryEventConsumer, compositeBulkheadCustomizer); registerEventConsumer(bulkheadRegistry, bulkheadEventConsumerRegistry, bulkheadConfigurationProperties); bulkheadConfigurationProperties.getInstances().forEach((name, properties) -> bulkheadRegistry .bulkhead(name, bulkheadConfigurationProperties .createBulkheadConfig(properties, compositeBulkheadCustomizer, name))); return bulkheadRegistry; }  @Bean @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer(
        @Autowired(required = false) List<BulkheadConfigCustomizer> customizers); @Bean BulkheadRegistry bulkheadRegistry(
        BulkheadConfigurationProperties bulkheadConfigurationProperties,
        EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry,
        RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer,
        @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer); @Bean @Primary RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer(
        Optional<List<RegistryEventConsumer<Bulkhead>>> optionalRegistryEventConsumers); @Bean @Conditional(value = {AspectJOnClasspathCondition.class}) BulkheadAspect bulkheadAspect(
        BulkheadConfigurationProperties bulkheadConfigurationProperties,
        ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry,
        BulkheadRegistry bulkheadRegistry,
        @Autowired(required = false) List<BulkheadAspectExt> bulkHeadAspectExtList,
        FallbackDecorators fallbackDecorators,
        SpelResolver spelResolver
    ); @Bean @Conditional(value = {RxJava2OnClasspathCondition.class, AspectJOnClasspathCondition.class}) RxJava2BulkheadAspectExt rxJava2BulkHeadAspectExt(); @Bean @Conditional(value = {ReactorOnClasspathCondition.class, AspectJOnClasspathCondition.class}) ReactorBulkheadAspectExt reactorBulkHeadAspectExt(); @Bean EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry(); }
BulkheadConfiguration { @Bean public BulkheadRegistry bulkheadRegistry( BulkheadConfigurationProperties bulkheadConfigurationProperties, EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry, RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer, @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer) { BulkheadRegistry bulkheadRegistry = createBulkheadRegistry(bulkheadConfigurationProperties, bulkheadRegistryEventConsumer, compositeBulkheadCustomizer); registerEventConsumer(bulkheadRegistry, bulkheadEventConsumerRegistry, bulkheadConfigurationProperties); bulkheadConfigurationProperties.getInstances().forEach((name, properties) -> bulkheadRegistry .bulkhead(name, bulkheadConfigurationProperties .createBulkheadConfig(properties, compositeBulkheadCustomizer, name))); return bulkheadRegistry; }  @Bean @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer(
        @Autowired(required = false) List<BulkheadConfigCustomizer> customizers); @Bean BulkheadRegistry bulkheadRegistry(
        BulkheadConfigurationProperties bulkheadConfigurationProperties,
        EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry,
        RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer,
        @Qualifier("compositeBulkheadCustomizer") CompositeCustomizer<BulkheadConfigCustomizer> compositeBulkheadCustomizer); @Bean @Primary RegistryEventConsumer<Bulkhead> bulkheadRegistryEventConsumer(
        Optional<List<RegistryEventConsumer<Bulkhead>>> optionalRegistryEventConsumers); @Bean @Conditional(value = {AspectJOnClasspathCondition.class}) BulkheadAspect bulkheadAspect(
        BulkheadConfigurationProperties bulkheadConfigurationProperties,
        ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry,
        BulkheadRegistry bulkheadRegistry,
        @Autowired(required = false) List<BulkheadAspectExt> bulkHeadAspectExtList,
        FallbackDecorators fallbackDecorators,
        SpelResolver spelResolver
    ); @Bean @Conditional(value = {RxJava2OnClasspathCondition.class, AspectJOnClasspathCondition.class}) RxJava2BulkheadAspectExt rxJava2BulkHeadAspectExt(); @Bean @Conditional(value = {ReactorOnClasspathCondition.class, AspectJOnClasspathCondition.class}) ReactorBulkheadAspectExt reactorBulkHeadAspectExt(); @Bean EventConsumerRegistry<BulkheadEvent> bulkheadEventConsumerRegistry();  }