Replace accepts_event_type with accepts_event.

This is in preparation for allowing queues to only accept some
messages.

(imported from commit 6bca11a9084aeff52931762085c4c771edbce56e)
This commit is contained in:
Tim Abbott
2013-12-10 10:35:16 -05:00
parent bd977e9e5c
commit 48963c1cdf
2 changed files with 22 additions and 14 deletions

View File

@@ -113,10 +113,14 @@ class ClientDescriptor(object):
return True
return False
def accepts_event_type(self, type):
def accepts_event(self, event):
if self.event_types is None:
return True
return type in self.event_types
return event["type"] in self.event_types
# TODO: Refactor so we don't need this function
def accepts_messages(self):
return self.event_types is None or "message" in self.event_types
def idle(self, now):
if not hasattr(self, 'queue_timeout'):
@@ -379,9 +383,8 @@ def load_event_queues():
def send_restart_events():
event = dict(type='restart', server_generation=settings.SERVER_GENERATION)
for client in clients.itervalues():
if not client.accepts_event_type('restart'):
continue
client.add_event(event.copy())
if client.accepts_event(event):
client.add_event(event.copy())
def setup_event_queue():
load_event_queues()