Skip to main content

A simple, class based dispatcher

Project description

Callouts - a minimalist dispatch system

A python module implementing lose, class-based coupling.

Imagine we had an application that checks weather for one place, but using multiple service. The functionality to get weather for a specific service could be implemented in individual modules.

To implement this with callouts, we first need to implement the extensibility base by creating a class with the @callouts.base decorator.

class Weather:
    def get_for(location: str) -> str: 

Now, individual implementations can be added simply by extending the class and implementing the get_for method.

class FirstWeatherService(Weather):
    def get_for(location: str) -> str: 
        return 'sunny' 
class SecondWeatherService(Weather):
    def get_for(location: str) -> str: 
        return 'cloudy'

with those definition in place, as soon as the modes are loaded it is possible to get both weathers by calling the get_for method on the Weather class:


will print out

['sunny', 'cloudy']

Project details

Download files

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

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

callouts-0.2.2-py3.10.egg (4.5 kB view hashes)

Uploaded 0 2 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page