From bfe9faad5abf429b7023aaaeb3ba3200a75bf485 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 27 Aug 2014 15:33:52 +0100 Subject: Index sources in a nicer fashion. --- synapse/streams/events.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'synapse/streams') diff --git a/synapse/streams/events.py b/synapse/streams/events.py index 8a84a9d392..2e6ea6ca26 100644 --- a/synapse/streams/events.py +++ b/synapse/streams/events.py @@ -20,8 +20,6 @@ from synapse.types import StreamToken class RoomEventSource(object): - SIGNAL_NAME = "RoomEventSource" - def __init__(self, hs): self.store = hs.get_datastore() @@ -70,8 +68,6 @@ class RoomEventSource(object): class PresenceSource(object): - SIGNAL_NAME = "PresenceSource" - def __init__(self, hs): self.hs = hs self.clock = hs.get_clock() @@ -150,13 +146,16 @@ class PresenceSource(object): class EventSources(object): - SOURCE_TYPES = [ - RoomEventSource, - PresenceSource, - ] + SOURCE_TYPES = { + "room": RoomEventSource, + "presence": PresenceSource, + } def __init__(self, hs): - self.sources = [t(hs) for t in EventSources.SOURCE_TYPES] + self.sources = { + name: cls(hs) + for name, cls in EventSources.SOURCE_TYPES.items() + } @staticmethod def create_token(events_key, presence_key): @@ -164,8 +163,8 @@ class EventSources(object): @defer.inlineCallbacks def get_current_token(self): - events_key = yield self.sources[0].get_current_token_part() - presence_key = yield self.sources[1].get_current_token_part() + events_key = yield self.sources["room"].get_current_token_part() + presence_key = yield self.sources["presence"].get_current_token_part() token = EventSources.create_token(events_key, presence_key) defer.returnValue(token) -- cgit 1.4.1