Skip to content

Commit

Permalink
Fine tuning db connection (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaesivsm committed Jun 16, 2024
1 parent 4eb8ea3 commit 6b6f07a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jarr/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ def init_logging(log_path=None, log_level=logging.INFO, modules=(),

def init_db(echo=False):
mapper_registry = registry()
new_engine = create_engine(conf.db.pg_uri, echo=echo)
new_engine = create_engine(
conf.db.pg_uri,
echo=echo,
pool_size=conf.db.postgres.pool_size,
max_overflow=conf.db.postgres.max_overflow,
pool_recycle=conf.db.postgres.pool_recycle,
pool_pre_ping=conf.db.postgres.pool_pre_ping,
pool_use_lifo=conf.db.postgres.pool_use_lifo,
)
NewBase = mapper_registry.generate_base()
new_session = scoped_session(sessionmaker(bind=new_engine))
return mapper_registry, new_engine, new_session, NewBase
Expand Down
6 changes: 6 additions & 0 deletions jarr/metaconf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ parameters:
- server_name: {'default': '', 'type': 'str'}
- db:
- pg_uri: {'default': 'postgresql://postgresql/jarr'}
- postgres:
- pool_size: {'default': 10}
- max_overflow: {'default': 2}
- pool_recycle: {'default': 300}
- pool_pre_ping: {'default': true}
- pool_use_lifo: {'default': true}
- redis:
- host: {'default': 'redis'}
- db: {'default': 1}
Expand Down

0 comments on commit 6b6f07a

Please sign in to comment.