saturnin.component.single¶
Single service controller and executor.
Classes¶
- class saturnin.component.single.SingleController(*args, **kwargs)[source]¶
Bases:
LoggingIdMixin
,TracedMixin
Service controller that manages service executed directly or in separate thread.
- __init__(*, parser: ConfigParser = None, manager: ChannelManager = None, direct: bool = False)[source]¶
- Parameters:
controller_class – Inner controller class.
parser (ConfigParser) – ConfigParser instance to be used for service configuration.
manager (ChannelManager) – ChannelManager to be used.
direct (bool) – Use DirectController or ThreadController.
- configure(*, section: str = 'service') None [source]¶
- Parameters:
section (str) – Configuration section with service specification.
- Return type:
None
- join(timeout=None) None [source]¶
Wait until service stops.
- Parameters:
timeout – Floating point number specifying a timeout for the operation in seconds (or fractions thereof).
- Return type:
None
- start(*, timeout: int = 10000) None [source]¶
Starts service.
- Parameters:
timeout (int) – Timeout for starting the service.
None
(infinity), or a floating point number specifying a timeout for the operation in seconds (or fractions thereof) [Default: 10s].- Raises:
ServiceError – On error in communication with service.
TimeoutError – When service does not start in time.
- Return type:
None
- stop(*, timeout: int = 10000) None [source]¶
Stop runing service.
- Parameters:
timeout (int) – Timeout for stopping the service.
None
(infinity), or a floating point number specifying a timeout for the operation in seconds (or fractions thereof) [Default: 10s].- Raises:
ServiceError – On error in communication with service.
TimeoutError – When service does not stop in time.
- Return type:
None
- config: ConfigParser¶
ConfigParser with service configuration
- controller: ThreadController | DirectController¶
Service controller
- mngr: ChannelManager¶
Channel manager
- class saturnin.component.single.SingleExecutor(log_context: Any, *, direct: bool = False)[source]¶
Bases:
object
Single service executor context manager.
- Parameters:
log_context (Any) –
direct (bool) –
- __init__(log_context: Any, *, direct: bool = False)[source]¶
- Parameters:
log_context (Any) – Log context for this executor.
direct (bool) – Use
DirectController
(True) orThreadController
.
- run() List[Tuple[str, Outcome, List[str]]] [source]¶
Runs the service in main or separate thread.
- Returns:
Tuple with (service_name, outcome, details).
- Return type:
outcome:
Outcome
of service execution. details: List of strings with additional outcome information (typically error text)
- controller: SingleController¶
Controller
- mngr: ChannelManager¶
Channel manager