File tree Expand file tree Collapse file tree 9 files changed +43
-42
lines changed
packages/service-library/src/servicelib/long_running_interfaces Expand file tree Collapse file tree 9 files changed +43
-42
lines changed Original file line number Diff line number Diff line change 66 ResultModel ,
77 StartParams ,
88)
9- from ._rpc .server import BaseServerJobInterface
109from ._server import Server
10+ from .runners .base import BaseServerJobInterface
1111
1212__all__ = (
1313 "BaseServerJobInterface" ,
Original file line number Diff line number Diff line change 11import traceback
2- from abc import ABC , abstractmethod
32from datetime import timedelta
4- from typing import Any
53
64from servicelib .rabbitmq import RPCRouter
75from settings_library .rabbit import RabbitSettings
1715 ResultModel ,
1816 StartParams ,
1917)
18+ from ..runners .base import BaseServerJobInterface
2019from ._utils import get_rpc_namespace
2120
2221
23- class BaseServerJobInterface (ABC ):
24- """allows the server side jobs to be implemented however the user pleases"""
25-
26- @abstractmethod
27- async def start (
28- self ,
29- name : RemoteHandlerName ,
30- unique_id : JobUniqueId ,
31- params : StartParams ,
32- timeout : timedelta , # noqa: ASYNC109
33- ) -> None :
34- """used to start a job"""
35-
36- @abstractmethod
37- async def remove (self , unique_id : JobUniqueId ) -> None :
38- """aborts and removes a job"""
39-
40- @abstractmethod
41- async def is_present (self , unique_id : JobUniqueId ) -> bool :
42- """returns True if the job exists"""
43-
44- @abstractmethod
45- async def is_running (self , unique_id : JobUniqueId ) -> bool :
46- """returns True if the job is currently running"""
47-
48- @abstractmethod
49- async def get_result (self , unique_id : JobUniqueId ) -> Any | None :
50- """provides the result of the job once finished"""
51-
52-
5322class ServerRPCInterface :
5423 def __init__ (
5524 self ,
Original file line number Diff line number Diff line change 11from settings_library .rabbit import RabbitSettings
22
33from ._models import LongRunningNamespace
4- from ._rpc .server import BaseServerJobInterface , ServerRPCInterface
4+ from ._rpc .server import ServerRPCInterface
5+ from .runners .base import BaseServerJobInterface
56
67
78class Server :
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 55
66from pydantic import NonNegativeFloat
77
8- from ...async_utils import cancel_wait_task
9- from ...long_running_interfaces import (
10- BaseServerJobInterface ,
11- JobUniqueId ,
12- RemoteHandlerName ,
13- StartParams ,
14- )
8+ from ....async_utils import cancel_wait_task
9+ from ..._models import JobUniqueId , RemoteHandlerName , StartParams
10+ from ...runners .base import BaseServerJobInterface
1511from ._errors import HandlerNotRegisteredError , TaskNotFoundError
1612from ._registry import AsyncTaskRegistry
1713
File renamed without changes.
Original file line number Diff line number Diff line change 11from collections .abc import Callable
22from typing import Any , Self , TypeVar
33
4- from ...long_running_interfaces import RemoteHandlerName
4+ from ..._models import RemoteHandlerName
55
66DecoratedCallable = TypeVar ("DecoratedCallable" , bound = Callable [..., Any ])
77
Original file line number Diff line number Diff line change 1+ from abc import ABC , abstractmethod
2+ from datetime import timedelta
3+ from typing import Any
4+
5+ from .._models import JobUniqueId , RemoteHandlerName , StartParams
6+
7+
8+ class BaseServerJobInterface (ABC ):
9+ """allows the server side jobs to be implemented however the user pleases"""
10+
11+ @abstractmethod
12+ async def start (
13+ self ,
14+ name : RemoteHandlerName ,
15+ unique_id : JobUniqueId ,
16+ params : StartParams ,
17+ timeout : timedelta , # noqa: ASYNC109
18+ ) -> None :
19+ """used to start a job"""
20+
21+ @abstractmethod
22+ async def remove (self , unique_id : JobUniqueId ) -> None :
23+ """aborts and removes a job"""
24+
25+ @abstractmethod
26+ async def is_present (self , unique_id : JobUniqueId ) -> bool :
27+ """returns True if the job exists"""
28+
29+ @abstractmethod
30+ async def is_running (self , unique_id : JobUniqueId ) -> bool :
31+ """returns True if the job is currently running"""
32+
33+ @abstractmethod
34+ async def get_result (self , unique_id : JobUniqueId ) -> Any | None :
35+ """provides the result of the job once finished"""
You can’t perform that action at this time.
0 commit comments