February 2018
Intermediate to advanced
456 pages
9h 56m
English
So far we've created a Redis Client with a single method. We now need to create a Nameko Dependency Provider to utilize this client for use with our services. In the same redis.py file, update your imports to include the following:
from nameko.extensions import DependencyProvider
Now, let's implement the following code:
class MessageStore(DependencyProvider):
def setup(self):
redis_url = self.container.config['REDIS_URL']
self.client = RedisClient(redis_url)
def stop(self):
del self.client
def get_dependency(self, worker_ctx):
return self.client
In the preceding code, you can see that our new MessageStore class inherits from the DependencyProvider class. The methods we have specified in our new MessageStore ...
Read now
Unlock full access