eventsourcingdb 2.2.0__tar.gz → 2.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/PKG-INFO +1 -1
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/container.py +34 -9
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/pyproject.toml +1 -1
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/.gitignore +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/LICENSE.md +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/README.md +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/bound.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/client.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/client_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/connection_stalled_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/custom_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/db_api_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/error_code.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/hash_verification_failed_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/incompatible_server_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/internal_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/is_outcome_unknown.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/outcome_unknown_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/server_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/signature_verification_failed_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/unsupported_hash_version_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/validation_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/event/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/event/event.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/event/event_candidate.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/event/find_raw_data.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/get_get_headers.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/get_post_headers.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/http_client.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/request_state.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/response.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/stall_guard.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/is_valid_server_header.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/observe_events/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/observe_events/if_event_is_missing_during_observe.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/observe_events/observe_events_options.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/observe_events/observe_from_latest_event.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/pandas.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/parse_raw_message.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/py.typed +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_event_types/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_event_types/event_type.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_events/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_events/if_event_is_missing_during_read.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_events/order.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_events/read_events_options.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_events/read_from_latest_event.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_subjects/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_subjects/read_subjects_options.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/choose_transport.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/error_of_answer.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/guard_write.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/statuses_without_v2_api.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/stream_broke_off.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/transport.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/code_of_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_event.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_event_type.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_heartbeat.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_stream_error.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_subject.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/parse_event_type.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/transport.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v2/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v2/envelopes.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v2/transport.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/write_events/__init__.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/write_events/precondition_options.py +0 -0
- {eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/write_events/preconditions.py +0 -0
|
@@ -16,6 +16,7 @@ from docker import DockerClient, errors
|
|
|
16
16
|
from docker.models.containers import Container as DockerContainer
|
|
17
17
|
|
|
18
18
|
from .client import Client
|
|
19
|
+
from .transport.statuses_without_v2_api import STATUSES_WITHOUT_V2_API
|
|
19
20
|
|
|
20
21
|
logger = logging.getLogger(__name__)
|
|
21
22
|
|
|
@@ -36,6 +37,9 @@ LOG_TAIL_LINES = 20
|
|
|
36
37
|
PING_TIMEOUT_SECONDS = 1
|
|
37
38
|
POLL_INTERVAL_SECONDS = 0.1
|
|
38
39
|
|
|
40
|
+
V1_PING_PATH = "/api/v1/ping"
|
|
41
|
+
V2_PING_PATH = "/api/v2/system/ping"
|
|
42
|
+
|
|
39
43
|
|
|
40
44
|
def _format_seconds(seconds: float) -> str:
|
|
41
45
|
# Whole seconds without a fraction, others as short as possible, such as 1.5.
|
|
@@ -328,23 +332,44 @@ class Container:
|
|
|
328
332
|
return None
|
|
329
333
|
|
|
330
334
|
mapped_port = self._extract_port_from_container_info(container.attrs)
|
|
331
|
-
if mapped_port is not None and self.
|
|
332
|
-
f"http://{self._host}:{mapped_port}
|
|
333
|
-
min(remaining, PING_TIMEOUT_SECONDS),
|
|
335
|
+
if mapped_port is not None and self._is_database_ready(
|
|
336
|
+
f"http://{self._host}:{mapped_port}", deadline
|
|
334
337
|
):
|
|
335
338
|
return mapped_port
|
|
336
339
|
|
|
337
340
|
time.sleep(max(min(POLL_INTERVAL_SECONDS, deadline - time.monotonic()), 0))
|
|
338
341
|
|
|
339
|
-
def
|
|
342
|
+
def _is_database_ready(self, base_url: str, deadline: float) -> bool:
|
|
343
|
+
# The v1 API is asked only where the server lacks the v2 API, since a
|
|
344
|
+
# later release of EventSourcingDB removes it. Any other failure means
|
|
345
|
+
# that the server is not ready yet, so the next attempt asks the v2 API
|
|
346
|
+
# again, rather than remembering an answer of a server that may still
|
|
347
|
+
# be starting. The statuses that tell a server without the v2 API are
|
|
348
|
+
# shared with the client, but not the way the client chooses its API,
|
|
349
|
+
# so that the readiness of the container that tests the client does
|
|
350
|
+
# not depend on what those tests are meant to check.
|
|
351
|
+
status = self._ping(f"{base_url}{V2_PING_PATH}", deadline)
|
|
352
|
+
if status == HTTPStatus.OK:
|
|
353
|
+
return True
|
|
354
|
+
if status not in STATUSES_WITHOUT_V2_API:
|
|
355
|
+
return False
|
|
356
|
+
|
|
357
|
+
return self._ping(f"{base_url}{V1_PING_PATH}", deadline) == HTTPStatus.OK
|
|
358
|
+
|
|
359
|
+
def _ping(self, url: str, deadline: float) -> int | None:
|
|
360
|
+
remaining = deadline - time.monotonic()
|
|
361
|
+
if remaining <= 0:
|
|
362
|
+
return None
|
|
363
|
+
|
|
364
|
+
# Bandit sees that a request has a bound only if it is passed by name.
|
|
365
|
+
timeout = min(remaining, PING_TIMEOUT_SECONDS)
|
|
366
|
+
|
|
367
|
+
# The ping needs no API token, so it gets none.
|
|
340
368
|
try:
|
|
341
369
|
response = requests.get(url, timeout=timeout)
|
|
342
370
|
except requests.RequestException:
|
|
343
|
-
return
|
|
344
|
-
return
|
|
345
|
-
|
|
346
|
-
def _check_response_ok(self, response: requests.Response) -> bool:
|
|
347
|
-
return response is not None and response.status_code == HTTPStatus.OK
|
|
371
|
+
return None
|
|
372
|
+
return response.status_code
|
|
348
373
|
|
|
349
374
|
def with_api_token(self, token: str) -> "Container":
|
|
350
375
|
self._api_token = token
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/connection_stalled_error.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/incompatible_server_error.py
RENAMED
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/is_outcome_unknown.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/errors/outcome_unknown_error.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/get_get_headers.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/get_post_headers.py
RENAMED
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/http_client/request_state.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_event_types/__init__.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_event_types/event_type.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/read_events/read_events_options.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/choose_transport.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/error_of_answer.py
RENAMED
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/statuses_without_v2_api.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/stream_broke_off.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/code_of_error.py
RENAMED
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_event_type.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_heartbeat.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/is_stream_error.py
RENAMED
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/transport/v1/parse_event_type.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/write_events/precondition_options.py
RENAMED
|
File without changes
|
{eventsourcingdb-2.2.0 → eventsourcingdb-2.2.2}/eventsourcingdb/write_events/preconditions.py
RENAMED
|
File without changes
|