Skip to main content

A dependency injection container with plugins approach

Project description

Sashimono

Coverage Status made-with-python GitHub license

A dependency injection container with a plugin approach

This package provides a DI container that can be populated using a plugin approach. This allows for code modularization and flexibility in application development.

Motivation

The main goal of 'sashimono' is to split application development into multiple packages in a coherent way, allowing each piece to be developed and maintained in isolated environments without compromising the whole application and its integration.

Architecture Notes

  • DI Container: Acts as a centralized registry of components. It takes care of dependency injection.
  • Plugins System: Acts as an entry point for container population. It allows for the integration of new features without modifying existing code.

Example

Defining Plugins

# Imagine this in the plugin/number.py file in a package named 'plugin'
class NumberPlugin:
    def setup(self, container):
        container['number'] = container.singleton(5)

Defining Package Configuration for Plugin Setup

[project]
name = "plugin"
version = "0.1.0"
description = "A sashimono plugin"
readme = "README.md"
requires-python = ">=3.12"
dependencies = ["setuptools>=75.8.2", "sashimono"]

[project.entry-points."sashimono.plugins"]
number = "plugin.number:NumberPlugin"

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

How to Use It

We need to load the sashimono container:

from sashimono import Container

c = Container()
print(c["number"])

The output must be '5'.

Benefits

  • Modularity: Allows for independent maintainability and development of application shards.
  • Extensibility: Allows for the addition of new features without editing existing code.
  • Flexibility: Eases configuration management and application personalization.

Happy coding! 👋

Project details


Download files

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

Source Distribution

sashimono-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sashimono-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file sashimono-0.1.1.tar.gz.

File metadata

  • Download URL: sashimono-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for sashimono-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8a0b5956750f7cbb2408007f2ee5abb93cf2c3acf7981041e57769c243548d45
MD5 d811cd81d971b5d0add53396aabf2ce0
BLAKE2b-256 71221fc31f84faea70beb719b236c27374154aa6af76beb95b1d99b3f78a780a

See more details on using hashes here.

File details

Details for the file sashimono-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sashimono-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for sashimono-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4dae978075123ab438b788be47fc40738f05eb7d658b8b5a488cbde06d39b40
MD5 ed902235d3e66e6b741130f8f584dda7
BLAKE2b-256 5bade490c2c35426608725e27bf3b709cbea269f81984f42de1a5ec1f1f2c5dc

See more details on using hashes here.

Supported by

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