Comments (1)
I'll try to walk you through:
get_bidding_details
is a GetBiddingDetails
query handler as it is decorated with @bidding_module.query_handler
.
When calling application.execute_query(GetBiddingDetails(...))
, get_bidding_details
is being called within a TransactionContext. The role of a TransactionContext
is to inject any parameters required by a function (via its dependency provider).
This is the query execution flow flow:
- TransactionContext is entered (https://github.com/pgorecki/python-ddd/blob/79f9558a8d6a7e97e7f7b3fdb084517fd43ee6b1/src/config/container.py#L103C9-L103C37), a new session is created
- The handler's params are provided by TransactionContext, and the handler is executed
- TransactionContext is exited (
python-ddd/src/config/container.py
Line 115 in 79f9558
Note that:
- TransactionContext uses
IocProvider
to provide any dependencies the handler requires. - some of the dependencies are transaction scoped (i.e. session, repositories, logger), and some of them are singletons (i.e. sqlalchemy engine) - that's why we have
TransactionContainer
andTopLevelContainer
.
Now let's back to your original question about the number of database connections. This is controlled by the pool_size
parameter of create_engine
, which defaults to 5. (https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine.params.pool_size)
More about pooling: https://docs.sqlalchemy.org/en/20/core/pooling.html
Hope this helps.
from python-ddd.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-ddd.