saturnin.component.micro¶
Saturnin base module for implementation of Firebird Butler Microservices.
Constants and variables¶
Classes¶
- class saturnin.component.micro.MicroService(*args, **kwargs)[source]¶
Bases:
Component
,TracedMixin
Saturnin Component for Firebird Burler Microservices.
- __init__(zmq_context: Context, descriptor: ServiceDescriptor, *, peer_uid: UUID = None)[source]¶
- Parameters:
zmq_context (Context) – ZeroMQ Context.
descriptor (ServiceDescriptor) – Service descriptor.
peer_uid (UUID) – Peer ID,
None
means that newly generated UUID type 1 should be used.
- aquire_resources() None [source]¶
Aquire resources required by component (open files, connect to other services etc.).
Must raise an exception when resource aquisition fails.
- Return type:
None
- handle_config_request(config: ConfigProto) None [source]¶
ICCP event handler. Called when controller requested reconfiguration.
Must raise an exception if configuration fails for any reason.
By default, the component does not support run-time configuration, so it raises NotImplementedError.
- Parameters:
config (ConfigProto) – New configuration provided by controller.
- Return type:
None
- handle_stop_component(exc: Exception = None) None [source]¶
ICCP event handler. Called when commponent should stop its operation. It stops the component by setting the
stop
event.- Parameters:
exc (Exception) – Exception that describes the reason why component should stop. If not provided, the component should stop on controller’s request.
- Return type:
None
- initialize(config: ComponentConfig) None [source]¶
Verify configuration and assemble component structural parts.
- Parameters:
config (ComponentConfig) – Service configuration.
- Return type:
None
- release_resources() None [source]¶
Release resources aquired by component (close files, disconnect from other services etc.)
- Return type:
None
- schedule(action: Callable, after: int) None [source]¶
Schedule action to be executed after specified time.
Action is executed in
run()
main I/O loop not sooner than after specified number of milliseconds from time whenschedule()
is called. However, the actual delay could be longer than specified (depends on time spent in message handlers and other factors).- Parameters:
action (Callable) – Callable (without arguments) to be executed. Use
functools.partial
if callable requires arguments.after (int) – Delay in milliseconds.
- Return type:
None
- start_activities() None [source]¶
Start normal component activities.
Must raise an exception when start fails.
- Return type:
None
- warm_up(ctrl_addr: ZMQAddress | None) None [source]¶
Initializes the
ChannelManager
and connects component to control channel.- Parameters:
ctrl_addr (ZMQAddress | None) –
- Return type:
None
- descriptor: ServiceDescriptor¶
Service desriptor.
- endpoints: Dict[str, List[ZMQAddress]]¶
Dictionary with endpoints to which the component binds. Key is channel name, value is list of ZMQAddress instances. Initially empty.
- mngr: ChannelManager¶
ChannelManager instance.
- peer: PeerDescriptor¶
Peer descriptor for this component.