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

debug(host='127.0.0.1', port=7000)[source]

This starts debug logging server.

get_version(short_sha=True)[source]

Return the currently running version of the service

The REVISION file is created by Capistrano during deployment

production(host='127.0.0.1')[source]

This returns API instance, compatible with aiohttp.worker.GunicornWebWorker interface

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__
micro.common.service.get_config()[source]

Get the configuration manager

micro.common.service.get_service()[source]

Get the Service object