Service¶
The Service layer typically takes care of interacting with external applications: Databases, Remote Web APIs, Message Queues, etc.
Services can be connected and–to provide a good level of flexibility–supports both Inheritance and two types of Composition.
Check out the Connecting Services example to see how a service can integrate and interact with other services.
-
class
aioli.service.
BaseService
(unit, config_override=None)[source]¶ Base Service class
Parameters: unit – Attach to this unit
Variables: - app – Application instance
- registry – Application ImportRegistry
- unit – Parent Unit
- config – Unit configuration
- log – Unit logger
-
connect
(cls)[source]¶ Reuses existing instance of the given Service class, in the context of the Unit it was first registered with.
Parameters: cls – Service class Returns: Existing Service instance
-
integrate
(cls)[source]¶ Creates a new instance of the given Service class in the context of the current Unit.
Parameters: cls – Service class Returns: Integrated Service
-
on_shutdown
()¶ Called when the Application is shutting down gracefully
-
on_startup
()¶ Called after the Unit has been successfully attached to the Application and the Loop is available