saturnin.component.bundle¶
Saturnin service budle controller and executor.
Classes¶
- class saturnin.component.bundle.ServiceBundleConfig(name: str)[source]¶
Bases:
Config
Service bundle configuration.
- Parameters:
name (str) – Conf. section name
- agents: ConfigListOption¶
Agents (services) in bundle
- class saturnin.component.bundle.BundleThreadController(*args, **kwargs)[source]¶
Bases:
LoggingIdMixin
,TracedMixin
Service controller that manages collection of services executed in separate threads.
- __init__(*, parser: ConfigParser = None, manager: ChannelManager = None)[source]¶
- Parameters:
parser (ConfigParser) – ConfigParser instance to be used for bundle configuration.
manager (ChannelManager) – ChannelManager to be used.
- configure(*, section: str = 'bundle') None [source]¶
- Parameters:
section (str) – Configuration section with bundle definition.
- Return type:
None
- join(timeout=None) None [source]¶
Wait until all services stop.
- 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]¶
Start all services in bundle.
- Parameters:
timeout (int) – Timeout for starting each service. None (infinity), or a floating point number specifying a timeout for the operation in seconds (or fractions thereof) [Default: 10s].
- Return type:
None
Important
Services are started in order they are listed in bundle configuration. If any service fails to start, all previously started services are stopped.
- Raises:
ServiceError – On error in communication with service.
TimeoutError – When service does not start in time.
- Parameters:
timeout (int) –
- Return type:
None
- stop(*, timeout: int = 10000) None [source]¶
Stop all runing services in bundle. The services are stopped in the reverse order in which they were started.
- Parameters:
timeout (int) – Timeout for stopping each 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 bundle configuration
- mngr: ChannelManager¶
Channel manager
- services: List[ThreadController]¶
List with ThreadControllers for all service instances in bundle
- class saturnin.component.bundle.BundleExecutor(log_context: Any)[source]¶
Bases:
object
Service bundle executor context manager.
- Parameters:
log_context (Any) – Logging context for this instance.
- run() List[Tuple[str, Outcome, List[str]]] [source]¶
Runs services in bundle.
- Returns:
List with (service_name, outcome, details) tuples.
- Return type:
Tuple items:
service_name: Name used for service in bundle configuration.
outcome:
Outcome
of service execution.details: List of strings with additional outcome information (typically error text)
- controller: BundleThreadController¶
Controller
- mngr: ChannelManager¶
Channel manager