Skip to main content

No project description provided

Project description

anyioc

GitHub Build Status PyPI

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.12.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

anyioc-0.12.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anyioc-0.12.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.1 Linux/4.15.0-1077-gcp

File hashes

Hashes for anyioc-0.12.0.tar.gz
Algorithm Hash digest
SHA256 9e55c7039d08d6b69c601ea1251de0ed78813affcadf0b9db5166a152ac5c86b
MD5 f7dd1f0ca60b2fc83c4027c7fa4c308f
BLAKE2b-256 59d0fb48a397d096cfc5029965c7158f3dbd11227f787c8ff3d09492cd47424f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: anyioc-0.12.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.1 Linux/4.15.0-1077-gcp

File hashes

Hashes for anyioc-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2bce22159fbc15ff00143e5f45bad3fdc475735f992cbe67b3895ae7086f4f0f
MD5 0d1ccb3a52446c8836f64120ea55410d
BLAKE2b-256 257c12fa8632b4f459f4232e2669b029a08022b77cee09e073a4a638a3dc94fe

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