Ejemplo n.º 1
0
 async def sub(self, topic,
               channel) -> Union[NSQResponseSchema, NSQErrorSchema]:
     """Subscribe to the topic and channel"""
     validate_topic_channel_name(topic)
     validate_topic_channel_name(channel)
     response = await self.execute(NSQCommands.SUB, topic, channel)
     if isinstance(response, NSQResponseSchema):
         self._topic = topic
         self._channel = channel
         self._is_subscribed = True
     return response
Ejemplo n.º 2
0
 async def pub(self, topic: str, message: Any) -> TCPResponse:
     """Publish a message to a topic"""
     validate_topic_channel_name(topic)
     return await self.execute(NSQCommands.PUB, topic, data=message)
Ejemplo n.º 3
0
 async def pub(self, topic,
               message) -> Union[NSQResponseSchema, NSQErrorSchema]:
     """Publish a message to a topic"""
     validate_topic_channel_name(topic)
     return await self.execute(NSQCommands.PUB, topic, data=message)
Ejemplo n.º 4
0
def test_validation_topic_channel_name_with_exception(name: str):
    with pytest.raises(AssertionError):
        validate_topic_channel_name(name)
Ejemplo n.º 5
0
def test_validation_topic_channel_name(name: str):
    assert validate_topic_channel_name(name) is None