33 from threading
import Thread, Condition
36 """ Sits between incoming messages from a subscription, and the outgoing 37 publish method. Provides throttling / buffering capabilities. 39 When the parameters change, the handler may transition to a different kind 45 def __init__(self, previous_handler=None, publish=None):
84 class ThrottleMessageHandler(MessageHandler):
88 MessageHandler.handle_message(self, msg)
102 class QueueMessageHandler(MessageHandler, Thread):
105 Thread.__init__(self)
106 MessageHandler.__init__(self, previous_handler)
115 should_notify = len(self.
queue) == 0
116 self.queue.append(msg)
137 """ If throttle was set to 0, this pushes all buffered messages """ 149 if len(self.
queue) == 0:
155 MessageHandler.handle_message(self, self.
queue[0])
161 MessageHandler.handle_message(self, self.
queue[0])
def __init__(self, previous_handler)
def handle_message(self, msg)
def set_throttle_rate(self, throttle_rate)
def handle_message(self, msg)
def __init__(self, previous_handler=None, publish=None)
def handle_message(self, msg)
def set_queue_length(self, queue_length)