Skip to content

Commit 0656e61

Browse files
authored
Merge pull request #64 from modern-python/remove-checker
remove faststream healthcheck additional checker
2 parents 7a37df2 + 1e257e9 commit 0656e61

File tree

3 files changed

+1
-29
lines changed

3 files changed

+1
-29
lines changed

docs/introduction/configuration.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,3 @@ Additional params:
127127

128128
- `health_checks_path`
129129
- `health_checks_include_in_schema`
130-
131-
### Health checks FastStream
132-
133-
Additional params:
134-
135-
- `health_checks_additional_checker` - additional coroutine to check service health

lite_bootstrap/bootstrappers/faststream_bootstrapper.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class FastStreamConfig(HealthChecksConfig, LoggingConfig, OpentelemetryConfig, P
5555
application: "AsgiFastStream" = dataclasses.field(default_factory=lambda: AsgiFastStream())
5656
opentelemetry_middleware_cls: type[FastStreamTelemetryMiddlewareProtocol] | None = None
5757
prometheus_middleware_cls: type[FastStreamPrometheusMiddlewareProtocol] | None = None
58-
health_checks_additional_checker: typing.Callable[[], typing.Coroutine[bool, typing.Any, typing.Any]] | None = None
5958

6059

6160
@dataclasses.dataclass(kw_only=True, slots=True, frozen=True)
@@ -84,12 +83,7 @@ async def _define_health_status(self) -> bool:
8483
if not self.bootstrap_config.application or not self.bootstrap_config.application.broker:
8584
return False
8685

87-
additional_check = (
88-
await self.bootstrap_config.health_checks_additional_checker()
89-
if self.bootstrap_config.health_checks_additional_checker
90-
else True
91-
)
92-
return additional_check and await self.bootstrap_config.application.broker.ping(timeout=5)
86+
return await self.bootstrap_config.application.broker.ping(timeout=5)
9387

9488

9589
@dataclasses.dataclass(kw_only=True, frozen=True)

tests/test_faststream_bootstrap.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def broker() -> RedisBroker:
2424

2525
def build_faststream_config(
2626
broker: BrokerUsecase[typing.Any, typing.Any] | None = None,
27-
health_checks_additional_checker: typing.Callable[[], typing.Coroutine[bool, typing.Any, typing.Any]] | None = None,
2827
) -> FastStreamConfig:
2928
return FastStreamConfig(
3029
service_name="microservice",
@@ -40,7 +39,6 @@ def build_faststream_config(
4039
sentry_dsn="https://testdsn@localhost/1",
4140
health_checks_path="/custom-health/",
4241
logging_buffer_capacity=0,
43-
health_checks_additional_checker=health_checks_additional_checker,
4442
application=faststream.asgi.AsgiFastStream(
4543
broker,
4644
asyncapi_path=faststream.asgi.AsyncAPIRoute("/docs/"),
@@ -86,20 +84,6 @@ async def test_faststream_bootstrap_health_check_wo_broker() -> None:
8684
assert response.text == "Service is unhealthy"
8785

8886

89-
async def test_faststream_bootstrap_additional_health_checker(broker: RedisBroker) -> None:
90-
async def custom_checker() -> bool:
91-
return False
92-
93-
bootstrap_config = build_faststream_config(broker=broker, health_checks_additional_checker=custom_checker)
94-
bootstrapper = FastStreamBootstrapper(bootstrap_config=bootstrap_config)
95-
application = bootstrapper.bootstrap()
96-
test_client = TestClient(app=application)
97-
98-
response = test_client.get(bootstrap_config.health_checks_path)
99-
assert response.status_code == status.HTTP_500_INTERNAL_SERVER_ERROR
100-
assert response.text == "Service is unhealthy"
101-
102-
10387
def test_faststream_bootstrapper_not_ready() -> None:
10488
with emulate_package_missing("faststream"), pytest.raises(RuntimeError, match="faststream is not installed"):
10589
FastStreamBootstrapper(bootstrap_config=FastStreamConfig(application=faststream.asgi.AsgiFastStream()))

0 commit comments

Comments
 (0)