Service module reference¶
- class micro.common.service.Service(app, config, name, description, init_callbacks=(), finish_callbacks=(), log_configuration_class=<class 'micro.common.service.SiteLoggingConfiguration'>, config_site_path=('site', ))[source]¶
This class holds some internal configuration bits which are common to all HC services and is capable of managing application startup and shutdown. It creates configuration accessor interface object and takes care of proper config backend configuration and config preloading. This is necessary, since micro.web and micro.rest do not know anything about HC configuration, revision tracking and maybe more.
- __init__(app, config, name, description, init_callbacks=(), finish_callbacks=(), log_configuration_class=<class 'micro.common.service.SiteLoggingConfiguration'>, config_site_path=('site', ))[source]¶
Parameters: - name (str) – Microservice name
- description (str) – Description of the microservice
- app (micro.web.Micro) – Application instance to run
- init_callbacks – Iterable of callbacks to be performed on application start
- finish_callbacks – Iterable of callbacks to be performed
- log_configuration_class (aiolocals.log.LogConfiguration) – The class to use as micro.web logging configuration factory
- config_site_path – The path to access site config.
Class config: Configuration accessor interface object
May vary depending on configuration backend (‘site’) or (‘hipchat’, ‘site’) :type config_site_path: tuple
- config_site = None¶
Type: dict
- configure_logging(debug=False)[source]¶
Configure logging to log service version alongside the basic aiolocals stuff
- class micro.common.service.PreloadedConfig(preloads=(), backend_class=None, loop=None, **kwargs)[source]¶
This configuration accessor preloads some configs on start. You will want to use it instead of micro.config.Config in most cases.
- __init__(preloads=(), backend_class=None, loop=None, **kwargs)[source]¶
Initialize configuration accessor instance with possible preloading of config
Parameters: - preloads (collections.Iterable) – The list of config names to be preloaded
- backend_class (micro.config.backends.base.ConfigurationBackend) – The backend class to use
- loop (asyncio.BaseEventLoop) – The event loop to use with this config accessor instance
- kwargs (dict) – Keyworded arguments to pass onto configuration backends __init__