Skip to main content

Tacty

An extensible command bus for Python 3 inspired by the Tactician Project.

Introduction

A command bus is a software component that performs operations in which the data and the execution steps are decoupled. The data for the operation is contained in a Command object and the execution steps are contained in a Handler. The responsibility of the command bus is matching a Command with its Handler and execute it.

Tacty is a library that provides a command bus implementation that is extensbile and easy to use.

Basic Usage

# A Command class containing the required data for the operation is defined. 
class PrintNumberCommand:
    def __init__(self, number):
        self.number = number


# A Handler class that receives an instance of the command and contains the execution steps is defined.
class PrintNumberHandler(Handler):
    def handle(self, command: PrintNumberCommand):
        print(command.number)


# An instance of the Command is passed to the command bus for its execution.
command = PrintNumberCommand(300)
command_bus.handle(command)

Initialization

# A Resolver is a class that given a Command returns its Handler. The InMemoryResolver receives pairs of Command and Handlers keeping them connected in memory.
resolver = InMemoryResolver()
resolver.add_handler(PrintNumberCommand, PrintNumberHandler())

# The CommandHandlerMiddleware uses a resolver to match a Command with its Handler and executes it.
command_handler_middleware = CommandHandlerMiddleware(resolver)

# The CommandBus receives a list of middlewares that are executed when processing a Command. In order to fulfill its minimum functionality (executing a Handler given a Command) an instance of the CommandHandlerMiddleware must be passed as the last element.
command_bus = CommandBus([command_handler_middleware])

Examples

Find next some examples using Tacty:

Metadata

Release files for tacty 1.1.0

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

Source distribution (sdist)

Source distribution for tacty 1.1.0
File Size Uploaded Provenance Actions
tacty-1.1.0.tar.gz 4.7 kB Without provenance Details for tacty-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tacty 1.1.0
File Interpreter ABI Platform Actions
tacty-1.1.0-py3-none-any.whl Python 3 none any Details for tacty-1.1.0-py3-none-any.whl

Total release size: 23.4 kB

Release files / tacty-1.1.0.tar.gz

Download URL tacty-1.1.0.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
064ba0daeb3b43f2aaad4bd5cac64b8095ec72f9a44774e62124184444f9c2f7
BLAKE2b-256 checksum
How to use checksums
ea0e06490d4439d240e7e446d054727fa261d507c26e0f832c219652dc28ccfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / tacty-1.1.0-py3-none-any.whl

Download URL tacty-1.1.0-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3a809b8ef1f9bc26c8d8421ec1cf0497a6c52bd710684ff226be6510e8f1011
BLAKE2b-256 checksum
How to use checksums
41e429b2b0c0b25d8f8dab92d3cbeb433842dae6f5defdd14e34db11b624d813
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for tacty 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

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