Inversion of control (IoC) container that runs as a system process.
Implements: Container
Description
The ProcessContainer class allows you to create an inversion of control (IoC) container that runs as a system process.
Important points
- It processes command line arguments and handles unhandled exceptions and Ctrl-C signal to shutdown the container properly.
Command line arguments
- –config / -c path to a JSON or YAML file with the container’s configuration (default: “./config/config.yml”)
- –param / –params / -p configuration parameters
- –help / -h prints the container usage help
Constructors
Creates a new instance of the container.
ProcessContainer(name: str = None, description: str = None)
- name: str - (optional) container’s name (accessible via ContextInfo)
- description: str - (optional) container’s description (accessible via ContextInfo)
Fields
Instance methods
run
Runs the container by instantiating and running components inside the container.
It reads the container configuration, and creates, configures, references and opens components. On process exit; it closes, unreferences and destroys components in order to shutdown properly.
run()
Examples
container = ProcessContainer()
container.add_factory(MyComponentFactory())
container.run()