Skip to content
Snippets Groups Projects
Commit 8863624f authored by Erik Johnston's avatar Erik Johnston
Browse files

Comments

parent 756d4942
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
""" """
The storage layer is split up into multiple parts to allow Synapse to run The storage layer is split up into multiple parts to allow Synapse to run
against different configurations of databases (e.g. single or multiple against different configurations of databases (e.g. single or multiple
databases). The `data_stores` are classes that talk directly to a single databases). The `Database` class represents a single physical database. The
database and have associated schemas, background updates, etc. On top of those `data_stores` are classes that talk directly to a `Database` instance and have
there are (or will be) classes that provide high level interfaces that combine associated schemas, background updates, etc. On top of those there are classes
calls to multiple `data_stores`. 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 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 data stores associated with them (e.g. the schema version tables), which are
......
...@@ -31,11 +31,17 @@ logger = logging.getLogger(__name__) ...@@ -31,11 +31,17 @@ logger = logging.getLogger(__name__)
class SQLBaseStore(object): 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): def __init__(self, db_conn, hs):
self.hs = hs self.hs = hs
self._clock = hs.get_clock() self._clock = hs.get_clock()
self.database_engine = hs.database_engine 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() self.rand = random.SystemRandom()
def _invalidate_state_caches(self, room_id, members_changed): def _invalidate_state_caches(self, room_id, members_changed):
......
...@@ -211,6 +211,11 @@ class PerformanceCounters(object): ...@@ -211,6 +211,11 @@ class PerformanceCounters(object):
class Database(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 _TXN_ID = 0
def __init__(self, hs): def __init__(self, hs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment