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
config
object rather thanConfig
dependency provider -
The built-in
Config
dependency provider fromnameko.dependency_providers
has been deprecate. You should instead use thenameko.config
global. - Optional — Use the global
config
object 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
config
toServiceRpcProxy
orClusterRpcProxy
-
If you are using these standlone RPC clients from the
nameko.standalone
package, note that they no longer acceptconfig
as 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
–>ClusterRpcClient
ServiceRpcProxy
–>ServiceRpcClient
The old names are preserved for backwards compatibility.
Using config inside tests
- Required — Read global
config
rather than any of thex_config
fixtures -
There is a breaking change to the way that the
rabbit_config
,test_config
andempty_config
fixtures 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
config
tocontainer_factory
orrunner_factory
. -
If you are using these pytest fixtures, note that the
config
argument is now deprecated.See the detailed breakdown of these changes for more information.
Using a custom runner
- Required — Don’t pass
config
toServiceContainer
orServiceRunner
-
In Nameko 3, the
ServiceContainer
andServiceRunner
classes do not accept aconfig
argument anymore. If you are programmatically creating a service runner, rather than usingnameko run
in 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.