Built-in Dependency Providers

Nameko includes some commonly used dependency providers. This section introduces them and gives brief examples of their usage.


Config is a simple dependency provider that gives services read-only access to configuration values at run time, see Running a Service.

from nameko.dependency_providers import Config
from nameko.web.handlers import http

class Service:

    name = "test_config"

    config = Config()

    def foo_enabled(self):
        return self.config.get('FOO_FEATURE_ENABLED', False)

    @http('GET', '/foo')
    def foo(self, request):
        if not self.foo_enabled:
            return 403, "FeatureNotEnabled"

        return 'foo'