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.3.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.3-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sashimono-0.1.3.tar.gz
Algorithm Hash digest
SHA256 13f1054389499ef4870eddd8c79342a1889aa680ba48df25eaa9ac360e17f39d
MD5 3b2d995e8ac7604c967f2bcd4603feab
BLAKE2b-256 1e3b800966fbded36f4f282dfb7ab364741ff045db713895e02ea99e92e2f6d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sashimono-0.1.3-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.9

File hashes

Hashes for sashimono-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 581d23d8d2d537bd2597ab3c6c08dc37d229f5ecdac8515e7c5d5855e710b541
MD5 a2f419261126a65df7f7ae8869c9996f
BLAKE2b-256 00303ffe897f812f475d3ccff7bf32624393e4f22e4829747351569a90d9a696

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