Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

A services registry

Project description

A simple service registry for use within HIS, but useful elsewhere.

Services registered must extend an abstract base class, which acts as a contract or interface.


Services should be defined as follows

import abc

class ExampleContract(metaclass=abc.ABCMeta):

    def method(self):

class ExampleService(ExampleContract):

    def method(self):
        print("I'm an example")

Then register an instance of the service:

from almanac import services

s = ExampleService()

Finally, to retrieve a registered service you need to use the contract:

from almanac import services

s = services.get(ExampleContract)

Errors and Exceptions

If you try to register an object as a service which does not have an abstract parent then it will raise an InvalidServiceType exception.

Attempting to get a service which has not been registered will raise a ServiceNotFoundError exception.

Attempting to get a service with anything other than an abstract base class (e.g. the contract) will result in the system raising an InvalidContract exception

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for his.almanac, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size his.almanac-0.0.1.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page