Exemplo n.º 1
0
def unsubscribe(listener, topics=None):
    """
    unsubscribe listener from topic and log event
    """
    pubsub_logger.debug("UNSUBSCRIBE : %s unsubsrcibes from topic(s) %s",
                        name(listener), topics)
    Publisher().unsubscribe(listener, topics)
Exemplo n.º 2
0
def save_subscribe(listener, topic=ALL_TOPICS):
    """
    subscribe listener to topic and log event,
    unless listener is already subscribed
    """
    if not is_subscribed(listener, topic):
        subscribe(listener, topic)
    else:
        pubsub_logger.debug("save_subscribe prevented %s second subscription to topic %s", 
                            name(listener), topic)
Exemplo n.º 3
0
def subscribe(listener, topic=ALL_TOPICS):
    """
    subscribe listener to topic and log event
    """
    
    if is_subscribed(listener, topic):
        pubsub_logger.warning("%s already subscribed to topic %s!", name(listener), topic)
        
    pubsub_logger.debug("SUBSCRIBE: %s subscribes to topic %s", name(listener), topic)
    Publisher().subscribe(listener, topic)
Exemplo n.º 4
0
def save_subscribe(listener, topic=ALL_TOPICS):
    """
    subscribe listener to topic and log event,
    unless listener is already subscribed
    """
    if not is_subscribed(listener, topic):
        subscribe(listener, topic)
    else:
        pubsub_logger.debug(
            "save_subscribe prevented %s second subscription to topic %s",
            name(listener), topic)
Exemplo n.º 5
0
def subscribe(listener, topic=ALL_TOPICS):
    """
    subscribe listener to topic and log event
    """

    if is_subscribed(listener, topic):
        pubsub_logger.warning("%s already subscribed to topic %s!",
                              name(listener), topic)

    pubsub_logger.debug("SUBSCRIBE: %s subscribes to topic %s", name(listener),
                        topic)
    Publisher().subscribe(listener, topic)
Exemplo n.º 6
0
def receive(listener, message):
    """
    log reception of message by listener
    """    
    if not message:
        pubsub_logger.debug("RECEIVE: %s receives message", name(listener))
    elif message.data:
        pubsub_logger.debug("RECEIVE: %s receives message with topic %s and data %s",
                            name(listener), ".".join(message.topic), repr(message.data))
    else:
        pubsub_logger.debug("RECEIVE: %s receives message with topic %s",
                            name(listener), ".".join(message.topic))
Exemplo n.º 7
0
def receive(listener, message):
    """
    log reception of message by listener
    """
    if not message:
        pubsub_logger.debug("RECEIVE: %s receives message", name(listener))
    elif message.data:
        pubsub_logger.debug(
            "RECEIVE: %s receives message with topic %s and data %s",
            name(listener), ".".join(message.topic), repr(message.data))
    else:
        pubsub_logger.debug("RECEIVE: %s receives message with topic %s",
                            name(listener), ".".join(message.topic))
Exemplo n.º 8
0
def send(talker, topic=ALL_TOPICS, data=None):
    """
    send message from talker to topic and log event
    """
    pubsub_logger.debug(10 * "-" + " %s " + 60 * "-", topic)

    if data:
        pubsub_logger.debug("SEND: %s sends message for topic %s with data %s",
                            name(talker), topic, repr(data))
    else:
        pubsub_logger.debug("SEND: %s sends message for topic %s",
                            name(talker), topic)

    Publisher().sendMessage(topic, data)
Exemplo n.º 9
0
def send(talker, topic=ALL_TOPICS, data=None):
    """
    send message from talker to topic and log event
    """
    pubsub_logger.debug(10 * "-" + " %s " + 60 * "-", topic)
    
    if data:
        pubsub_logger.debug("SEND: %s sends message for topic %s with data %s",
                            name(talker), topic, repr(data))
    else:
        pubsub_logger.debug("SEND: %s sends message for topic %s", name(talker),
                            topic)
        
    Publisher().sendMessage(topic, data)
Exemplo n.º 10
0
def unsubscribe(listener, topics=None):
    """
    unsubscribe listener from topic and log event
    """
    pubsub_logger.debug("UNSUBSCRIBE : %s unsubsrcibes from topic(s) %s", name(listener), topics)
    Publisher().unsubscribe(listener, topics)