airtai / faststream

FastStream is a powerful and easy-to-use Python framework for building asynchronous services interacting with event streams such as Apache Kafka, RabbitMQ, NATS and Redis.
https://faststream.airt.ai/latest/
Apache License 2.0
3.15k stars 161 forks source link

fix: RabbitBroker's ping is more objective #1933

Closed roma-frolov closed 22 hours ago

roma-frolov commented 22 hours ago

Description

I have a situation where RabbitMQ is up, a service is up with a successful connection to RabbitMQ, I stop it, a reconnection occurs to it every n seconds.

in fact there is no connection, my /readiness handle returns 204, although the service is not readiness.

the ping method checks the connection's is_closed flag, although this is not entirely correct, because it will be True only when close/__del__/__aexit__ is called on the connection

checking the connected attribute of the connection object will be more objective: True when there is a connection, False when there is not (there was no connection right away, or a reconnection occurs)

Type of change

Checklist