core (memory/storage): backend storage is now based on SQLAlchemy
This commit is contained in:
parent
1ad8de5726
commit
a5f225e1ea
1 changed files with 1335 additions and 1784 deletions
|
|
@ -33,7 +33,7 @@ from sat.core.i18n import _
|
|||
from sat.core.log import getLogger
|
||||
from sat.core import exceptions
|
||||
from sat.core.constants import Const as C
|
||||
from sat.memory.sqlite import SqliteStorage
|
||||
from sat.memory.sqla import Storage
|
||||
from sat.memory.persistent import PersistentDict
|
||||
from sat.memory.params import Params
|
||||
from sat.memory.disco import Discovery
|
||||
|
|
@ -228,7 +228,6 @@ class Memory(object):
|
|||
|
||||
def __init__(self, host):
|
||||
log.info(_("Memory manager init"))
|
||||
self.initialized = defer.Deferred()
|
||||
self.host = host
|
||||
self._entities_cache = {} # XXX: keep presence/last resource/other data in cache
|
||||
# /!\ an entity is not necessarily in roster
|
||||
|
|
@ -240,19 +239,22 @@ class Memory(object):
|
|||
self.disco = Discovery(host)
|
||||
self.config = tools_config.parseMainConf(log_filenames=True)
|
||||
self._cache_path = Path(self.getConfig("", "local_dir"), C.CACHE_DIR)
|
||||
|
||||
async def initialise(self):
|
||||
database_file = os.path.expanduser(
|
||||
os.path.join(self.getConfig("", "local_dir"), C.SAVEFILE_DATABASE)
|
||||
)
|
||||
self.storage = SqliteStorage(database_file, host.version)
|
||||
self.storage = Storage(database_file, self.host.version)
|
||||
await self.storage.initialise()
|
||||
PersistentDict.storage = self.storage
|
||||
self.params = Params(host, self.storage)
|
||||
self.params = Params(self.host, self.storage)
|
||||
log.info(_("Loading default params template"))
|
||||
self.params.load_default_params()
|
||||
d = self.storage.initialized.addCallback(lambda ignore: self.load())
|
||||
await self.load()
|
||||
self.memory_data = PersistentDict("memory")
|
||||
d.addCallback(lambda ignore: self.memory_data.load())
|
||||
d.addCallback(lambda ignore: self.disco.load())
|
||||
d.chainDeferred(self.initialized)
|
||||
await self.memory_data.load()
|
||||
await self.disco.load()
|
||||
|
||||
|
||||
## Configuration ##
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue