Upgrading Services
This guide covers the steps to modify an existing service so that it works with Nameko 3.
Generally only three areas are affected:
Using config inside service code
- Optional — Use the global
configobject rather thanConfigdependency provider -
The built-in
Configdependency provider fromnameko.dependency_providershas been deprecate. You should instead use thenameko.configglobal. - Optional — Use the global
configobject to simplify service setup -
The global is available at all stages of the service lifecycle, including import time, which can make it much simpler to configure services.
- Required
— Don’t pass
configtoServiceRpcProxyorClusterRpcProxy -
If you are using these standlone RPC clients from the
nameko.standalonepackage, note that they no longer acceptconfigas a parameter.You must set up config in the global context before using them, for example with
nameko.config.patch.Also note that these have been renamed from:
ClusterRpcProxy–>ClusterRpcClientServiceRpcProxy–>ServiceRpcClient
The old names are preserved for backwards compatibility.
Using config inside tests
- Required
— Read global
configrather than any of thex_configfixtures -
There is a breaking change to the way that the
rabbit_config,test_configandempty_configfixtures work. They no longer return the config dictionary.If you are using one of these fixtures, see the recommended pattern in the detailed breakdown of these configuration changes.
- Optional — Don’t pass
configtocontainer_factoryorrunner_factory. -
If you are using these pytest fixtures, note that the
configargument is now deprecated.See the detailed breakdown of these changes for more information.
Using a custom runner
- Required
— Don’t pass
configtoServiceContainerorServiceRunner -
In Nameko 3, the
ServiceContainerandServiceRunnerclasses do not accept aconfigargument anymore. If you are programmatically creating a service runner, rather than usingnameko runin the CLI, you must set up config in the global context before using them, for example withnameko.config.patch.See the detailed breakdown of these changes for more information.