summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-01-28 14:46:08 +0000
committerErik Johnston <erik@matrix.org>2016-01-28 14:46:08 +0000
commit19fd4259284598a89036418de62e88a282db9566 (patch)
tree2129256c6f81a4274f18c36ccd81173780949c59 /synapse/storage
parentChange load limit params (diff)
parentMerge pull request #534 from matrix-org/erikj/setup (diff)
downloadsynapse-19fd4259284598a89036418de62e88a282db9566.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into erikj/sync
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/__init__.py27
1 files changed, 9 insertions, 18 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index c8cab45f77..eb88842308 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -61,22 +61,6 @@ logger = logging.getLogger(__name__)
 LAST_SEEN_GRANULARITY = 120*1000
 
 
-def get_datastore(hs):
-    logger.info("getting called!")
-
-    conn = hs.get_db_conn()
-    try:
-        cur = conn.cursor()
-        cur.execute("SELECT MIN(stream_ordering) FROM events",)
-        rows = cur.fetchall()
-        min_token = rows[0][0] if rows and rows[0] and rows[0][0] else -1
-        min_token = min(min_token, -1)
-
-        return DataStore(conn, hs, min_token)
-    finally:
-        conn.close()
-
-
 class DataStore(RoomMemberStore, RoomStore,
                 RegistrationStore, StreamStore, ProfileStore,
                 PresenceStore, TransactionStore,
@@ -98,10 +82,17 @@ class DataStore(RoomMemberStore, RoomStore,
                 EventPushActionsStore
                 ):
 
-    def __init__(self, db_conn, hs, min_stream_token):
+    def __init__(self, db_conn, hs):
         self.hs = hs
 
-        self.min_stream_token = min_stream_token
+        cur = db_conn.cursor()
+        try:
+            cur.execute("SELECT MIN(stream_ordering) FROM events",)
+            rows = cur.fetchall()
+            self.min_stream_token = rows[0][0] if rows and rows[0] and rows[0][0] else -1
+            self.min_stream_token = min(self.min_stream_token, -1)
+        finally:
+            cur.close()
 
         self.client_ip_last_seen = Cache(
             name="client_ip_last_seen",