summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-12-04 14:00:29 +0000
committerErik Johnston <erik@matrix.org>2019-12-05 10:46:37 +0000
commit8863624f7852ffc4a261aa9d17f6f7ddb5bf0c19 (patch)
tree964dcbc48f8af62a735880eb03b57bf4dee6c9ca
parentMove DB pool and helper functions into dedicated Database class (diff)
downloadsynapse-8863624f7852ffc4a261aa9d17f6f7ddb5bf0c19.tar.xz
Comments
-rw-r--r--synapse/storage/__init__.py8
-rw-r--r--synapse/storage/_base.py8
-rw-r--r--synapse/storage/database.py5
3 files changed, 16 insertions, 5 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 0460fe8cc9..8fb18203dc 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -17,10 +17,10 @@
 """
 The storage layer is split up into multiple parts to allow Synapse to run
 against different configurations of databases (e.g. single or multiple
-databases). The `data_stores` are classes that talk directly to a single
-database and have associated schemas, background updates, etc. On top of those
-there are (or will be) classes that provide high level interfaces that combine
-calls to multiple `data_stores`.
+databases). The `Database` class represents a single physical database. The
+`data_stores` are classes that talk directly to a `Database` instance and have
+associated schemas, background updates, etc. On top of those there are classes
+that provide high level interfaces that combine calls to multiple `data_stores`.
 
 There are also schemas that get applied to every database, regardless of the
 data stores associated with them (e.g. the schema version tables), which are
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py
index fd5bb3e1de..b7e27d4e97 100644
--- a/synapse/storage/_base.py
+++ b/synapse/storage/_base.py
@@ -31,11 +31,17 @@ logger = logging.getLogger(__name__)
 
 
 class SQLBaseStore(object):
+    """Base class for data stores that holds helper functions.
+
+    Note that multiple instances of this class will exist as there will be one
+    per data store (and not one per physical database).
+    """
+
     def __init__(self, db_conn, hs):
         self.hs = hs
         self._clock = hs.get_clock()
         self.database_engine = hs.database_engine
-        self.db = Database(hs)
+        self.db = Database(hs)  # In future this will be passed in
         self.rand = random.SystemRandom()
 
     def _invalidate_state_caches(self, room_id, members_changed):
diff --git a/synapse/storage/database.py b/synapse/storage/database.py
index c2e121a001..ac64d80806 100644
--- a/synapse/storage/database.py
+++ b/synapse/storage/database.py
@@ -211,6 +211,11 @@ class PerformanceCounters(object):
 
 
 class Database(object):
+    """Wraps a single physical database and connection pool.
+
+    A single database may be used by multiple data stores.
+    """
+
     _TXN_ID = 0
 
     def __init__(self, hs):