From 432f8627c97ae20f15c7603a7974047ade69a53d Mon Sep 17 00:00:00 2001 From: bvn13 Date: Thu, 30 Jun 2022 11:35:28 +0300 Subject: [PATCH] added feature toggling for enabling/disabling --- README.md | 15 ++++++++------- .../health/KafkaHealthAutoConfiguration.java | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 87d9432..9103af6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Add the following dependency to your `pom.xml` me.bvn13.kafka.health kafka-health-check - 1.5.0 + 1.5.4 ``` @@ -66,12 +66,13 @@ Now if you call the actuator endpoint `actuator/health` you should see the follo ## Configuration -| Property | Default | Description | -|------------------------------------|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| kafka.health.topic | `health-checks` | Topic to subscribe to | -| kafka.health.sendReceiveTimeout | 2.5s | The maximum time, given as [Duration](https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-conversion-duration), to wait for sending and receiving the message. | -| kafka.health.pollTimeout | 200ms | The time, given as [Duration](https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-conversion-duration), spent fetching the data from the topic | -| kafka.health.cache.maximumSize | 200 | Specifies the maximum number of entries the cache may contain. | +| Property | Default | Description | +|---------------------------------|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| kafka.health.enabled | false | Enabling kafka health check | +| kafka.health.topic | `health-checks` | Topic to subscribe to | +| kafka.health.sendReceiveTimeout | 2.5s | The maximum time, given as [Duration](https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-conversion-duration), to wait for sending and receiving the message.| +| kafka.health.pollTimeout | 200ms | The time, given as [Duration](https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-conversion-duration), spent fetching the data from the topic | +| kafka.health.cache.maximumSize | 200 | Specifies the maximum number of entries the cache may contain. | diff --git a/src/main/java/me/bvn13/kafka/health/KafkaHealthAutoConfiguration.java b/src/main/java/me/bvn13/kafka/health/KafkaHealthAutoConfiguration.java index a07e01c..1538116 100644 --- a/src/main/java/me/bvn13/kafka/health/KafkaHealthAutoConfiguration.java +++ b/src/main/java/me/bvn13/kafka/health/KafkaHealthAutoConfiguration.java @@ -3,6 +3,7 @@ package me.bvn13.kafka.health; import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.kafka.KafkaProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -10,6 +11,7 @@ import org.springframework.context.annotation.Configuration; @Configuration @ConditionalOnClass(AbstractHealthIndicator.class) +//@ConditionalOnProperty(name = "kafka.health.enabled", havingValue = "true") public class KafkaHealthAutoConfiguration { @Bean