Skip to main content

Another simple ioc framework for python

Project description

anyioc

GitHub CI PyPI GitHub code size in bytes

Another simple ioc framework for python.

Usage

from anyioc import ServiceProvider
provider = ServiceProvider()
provider.register_singleton('the key', lambda ioc: 102) # ioc will be a `IServiceProvider`
value = provider.get('the key')
assert value == 102

Register and resolve

By default, you can use following methods to register services:

  • ServiceProvider.register_singleton(key, factory)
  • ServiceProvider.register_scoped(key, factory)
  • ServiceProvider.register_transient(key, factory)
  • ServiceProvider.register(key, factory, lifetime)
  • ServiceProvider.register_value(key, value)
  • ServiceProvider.register_group(key, keys)
  • ServiceProvider.register_bind(new_key, target_key)

And use following methods to resolve services:

  • ServiceProvider.__getitem__(key)
  • ServiceProvider.get(key)
  • ServiceProvider.get_many(key)

get return None if the service was not found, but __getitem__ will raise a ServiceNotFoundError.

Read full documentation.

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

anyioc-0.13.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

anyioc-0.13.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file anyioc-0.13.1.tar.gz.

File metadata

  • Download URL: anyioc-0.13.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.7 Windows/10

File hashes

Hashes for anyioc-0.13.1.tar.gz
Algorithm Hash digest
SHA256 725725fe60ab9fddfe595c9a87d1da0dc1f1c7a63f2be9b270180fbbfa63afec
MD5 d4d7aa925a9e65eaa3bdaf3645210484
BLAKE2b-256 b31028b29186b1a559df3d55729e2ba76cf858590533b0383e3366f502d4fffe

See more details on using hashes here.

File details

Details for the file anyioc-0.13.1-py3-none-any.whl.

File metadata

  • Download URL: anyioc-0.13.1-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.7 Windows/10

File hashes

Hashes for anyioc-0.13.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82ca11f877b3b7685c8c65315b6ca90df3cb398c85e6bd3645334dae50de69b1
MD5 6aab74f199e551cef9cdc68b75a8fb79
BLAKE2b-256 347b12d88fb1c9fdee2d5d5e99d79aa513231d6bfd7b890638c2fd430879745f

See more details on using hashes here.

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