Skip to content
Snippets Groups Projects
Commit 1b3b5d9a authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Add db connection pool size config options

parent 23fadda5
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ class MessengerBridge(Bridge):
def prepare_db(self) -> None:
self.db = Database(self.config["appservice.database"], upgrade_table=upgrade_table,
loop=self.loop)
loop=self.loop, db_args=self.config["appservice.database_opts"])
init_db(self.db)
def prepare_bridge(self) -> None:
......@@ -83,6 +83,8 @@ class MessengerBridge(Bridge):
async def start(self) -> None:
await self.db.start()
await self.state_store.upgrade_table.upgrade(self.db.pool)
if self.matrix.e2ee:
self.matrix.e2ee.crypto_db.override_pool(self.db.pool)
self.add_startup_actions(User.init_cls(self))
self.add_startup_actions(Puppet.init_cls(self))
Portal.init_cls(self)
......
......@@ -27,6 +27,11 @@ appservice:
# The full URI to the database. Only Postgres is currently supported.
database: postgres://username:password@hostname/db
# Additional arguments for asyncpg.create_pool()
# https://magicstack.github.io/asyncpg/current/api/index.html#asyncpg.pool.create_pool
database_opts:
min_size: 5
max_size: 10
# Public part of web server for out-of-Matrix interaction with the bridge.
public:
......
......@@ -227,7 +227,7 @@ class Puppet(DBPuppet, BasePuppet):
async def get_by_mxid(cls, mxid: UserID, create: bool = True) -> Optional['Puppet']:
fbid = cls.get_id_from_mxid(mxid)
if fbid:
return await cls.get_by_fbid(fbid, create)
return await cls.get_by_fbid(fbid, create=create)
return None
@classmethod
......
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