In our service.py, we can now make use of our new Redis Dependency Provider. Let's start off by creating a new service, which will replace our Konnichiwa Service from earlier. First, we need to update our imports at the top of our file:
from .dependencies.redis import MessageStore
Now we can create our new service:
class MessageService: name = 'message_service' message_store = MessageStore() @rpc def get_message(self, message_id): return self.message_store.get_message(message_id)
This is similar to our earlier services; however, this time we are specifying a new class attribute, message_store. Our RPC entrypoint, get_message, can now make use of this and call get_message in our RedisClient and simply return ...