def map(self, msg):
        """
        Apply key function to ``msg`` to obtain a key. Return the routing table entry.
        """
        k = self.key_function(msg)
        key = k[0] if isinstance(k, (tuple, list)) else k
        return self.routing_table[key]