Skip to content

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

Notifications You must be signed in to change notification settings

a-musing-moose/almanac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alamanac

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.

Usage

Services should be defined as follows

import abc

class ExampleContract(metaclass=abc.ABCMeta):

    @abc.abstractmethod
    def method(self):
        pass


class ExampleService(ExampleContract):

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

Then register an instance of the service:

from almanac import services

s = ExampleService()
services.register(s)

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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published