This is the base class for all Asphalt components.
Perform any necessary tasks to start the services provided by this component.
- In this method, components typically use the context to:
It is advisable for Components to first add all the resources they can to the context before requesting any from it. This will speed up the dependency resolution and prevent deadlocks.
Parameters: ctx (
Context) – the containing context for this component
A component that can contain other components.
add_component(alias, type=None, **config)¶
Add a child component.
This will instantiate a component class, as specified by the
If the second argument is omitted, the value of
aliasis used as its value.
The locally given configuration can be overridden by component configuration parameters supplied to the constructor (via the
When configuration values are provided both as keyword arguments to this method and component configuration through the
componentsconstructor argument, the configurations are merged together using
merge_config()in a way that the configuration values from the
componentsargument override the keyword arguments to this method.
Specialized subclass of
ContainerComponentfor command line tools.
Command line tools and similar applications should use this as their root component and implement their main code in the
When all the subcomponents have been started,
run()is started as a new task. When the task is finished, the application will exit using the return value as its exit code.
run()raises an exception, a stack trace is printed and the exit code will be set to 1. If the returned exit code is out of range or of the wrong data type, it is set to 1 and a warning is emitted.
Run the business logic of the command line tool.
Do not call this method yourself.
Returns: the application’s exit code (0-127;