Strengthen is_connected with cached health probes.
Convert is_connected to a method that verifies backend liveness via TTL-cached ping (Redis) or bucket_exists (MinIO), with cache invalidation on connect/disconnect. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
fef9552cbf
commit
5149299c1b
@@ -115,7 +115,7 @@ def test_should_have_logger_when_instantiated() -> None:
|
||||
def test_should_not_be_connected_when_instantiated() -> None:
|
||||
"""Test that the MinioAdapter is not connected when instantiated."""
|
||||
adapter = MinioAdapter()
|
||||
assert not adapter.is_connected
|
||||
assert not adapter.is_connected()
|
||||
|
||||
|
||||
def test_should_log_info_when_already_connected(
|
||||
@@ -137,7 +137,7 @@ def test_should_raise_connection_error_when_unable_to_connect(
|
||||
adapter = MinioAdapter()
|
||||
with pytest.raises(ConnectionError):
|
||||
adapter.connect()
|
||||
assert not adapter.is_connected
|
||||
assert not adapter.is_connected()
|
||||
|
||||
|
||||
def test_should_log_info_when_creating_expected_bucket(
|
||||
@@ -163,7 +163,7 @@ def test_should_log_error_on_exception_during_exit(
|
||||
"""Test that the MinioAdapter logs an error if an exception occurs during __exit__."""
|
||||
try:
|
||||
with MinioAdapter() as adapter:
|
||||
assert adapter.is_connected
|
||||
assert adapter.is_connected()
|
||||
raise ValueError("Simulated error")
|
||||
except ValueError:
|
||||
pass # Expected
|
||||
|
||||
Reference in New Issue
Block a user