Skip to content

Commit f2a698f

Browse files
author
Andrei Neagu
committed
refactor
1 parent b303864 commit f2a698f

File tree

3 files changed

+3
-29
lines changed

3 files changed

+3
-29
lines changed

packages/service-library/src/servicelib/resilent_long_running/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ._client import Client
2-
from ._errors import FinishedWithError, TimedOutError
2+
from ._errors import AlreadyStartedError, FinishedWithError, TimedOutError
33
from ._models import (
44
JobUniqueId,
55
LongRunningNamespace,
@@ -11,6 +11,7 @@
1111
from .runners.base import BaseServerJobInterface
1212

1313
__all__ = (
14+
"AlreadyStartedError",
1415
"BaseServerJobInterface",
1516
"Client",
1617
"FinishedWithError",

packages/service-library/src/servicelib/resilent_long_running/_client.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,6 @@ def _get_correlation_id(*, is_unique: bool) -> CorrelationID:
4343

4444

4545
class Client:
46-
"""Client for managing and interacting with long-running remote jobs.
47-
48-
This class provides a resilient interface to schedule, track, and retrieve results from
49-
long-running jobs executing on remote servers. It implements fault tolerance through:
50-
51-
1. Automatic job tracking in Redis to preserve state across client restarts
52-
2. Configurable retry mechanism for handling transient errors
53-
3. Timeout management to prevent indefinite waiting
54-
4. Correlation ID system to deduplicate or uniquely identify job requests
55-
56-
Internally, the client relies on two main components:
57-
- RPC Interface: Handles communication with remote job handlers via RabbitMQ
58-
- Store Interface: Manages job state persistence in Redis
59-
60-
The client workflow:
61-
1. Generate a unique or reusable job ID based on parameters
62-
2. Track the job in Redis with remaining retry attempts
63-
3. Start the job on the remote server if not already running
64-
4. Poll for job status until completion or failure
65-
5. On failure, retry the job if attempts remain
66-
6. On success, verify result type and return data
67-
7. Clean up resources on both client and server side
68-
69-
This resilient approach ensures jobs can survive temporary network issues,
70-
service restarts, and transient failures in the distributed system.
71-
"""
72-
7346
def __init__(
7447
self,
7548
rabbit_settings: RabbitSettings,

packages/service-library/tests/resilient_long_running/test_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
from pydantic import NonNegativeInt, ValidationError
1313
from servicelib.async_utils import cancel_wait_task
1414
from servicelib.resilent_long_running import (
15+
AlreadyStartedError,
1516
Client,
1617
FinishedWithError,
1718
LongRunningNamespace,
1819
Server,
1920
TimedOutError,
2021
)
21-
from servicelib.resilent_long_running._client import AlreadyStartedError
2222
from servicelib.resilent_long_running._models import JobUniqueId
2323
from servicelib.resilent_long_running.runners.asyncio_tasks import (
2424
AsyncioTasksJobInterface,

0 commit comments

Comments
 (0)