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:
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:
Return type:

None

config: ConfigParser

ConfigParser with service configuration

controller: ThreadController | DirectController

Service controller

direct: bool

Use DirectController instead ThreadController

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:
configure(cfg_files: List[str], *, section: str = 'service') None[source]

Executor configuration.

Parameters:
  • cfg_files (List[str]) – List of configuration files.

  • section (str) – Configuration section name with service specification.

Return type:

None

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:

List[Tuple[str, Outcome, List[str]]]

outcome: Outcome of service execution. details: List of strings with additional outcome information (typically error text)

controller: SingleController

Controller

direct: bool

Use DirectController instead ThreadController

mngr: ChannelManager

Channel manager