Add get_msg_validators and test

This commit is contained in:
NIC619
2019-08-04 11:23:20 +08:00
parent 1ed14d0cc8
commit f8ca4fa1ef
2 changed files with 57 additions and 0 deletions

View File

@ -170,6 +170,13 @@ class Pubsub:
if topic in self.topic_validators:
del self.topic_validators[topic]
def get_msg_validators(self, msg: rpc_pb2.Message) -> Tuple[TopicValidator, ...]:
return (
self.topic_validators[topic]
for topic in msg.topicIDs
if topic in self.topic_validators
)
async def stream_handler(self, stream: INetStream) -> None:
"""
Stream handler for pubsub. Gets invoked whenever a new stream is created