Skip to main content

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.

@callouts.base
class Weather:
    def get_for(location: str) -> str: 
        pass 

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:

print(Weather.get_for('place'))

will print out

['sunny', 'cloudy']

Metadata

Release files for callouts 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for callouts 0.2.2
File Interpreter ABI Platform
callouts-0.2.2-py3.10.egg Legacy Egg format - - Details

Release files / callouts-0.2.2-py3.10.egg

Download URL callouts-0.2.2-py3.10.egg
Size 4.5 kB
Tags Egg
SHA-256 checksum
How to use checksums
d85490e58586d3ce523361bdbd6d098c26b4608d7a17f7f6b0f97e2edd64320e
BLAKE2b-256 checksum
How to use checksums
592273e7a4baa263a912121e6fafa16b78c5f0e0a4f8c85675251bb7494ddef8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page