Closed subhashb closed 5 years ago
There are two concerns mixed in the current Adapter
class: The act of retrieving and letting of database connections and the database CRUD operations of each entity.
I propose we split the existing Adapter class into Provider
and Repository
.
Provider
:
Repository
:
Entity
and Database using the Model
Typical control flow for a single Entity operation (like one executed in a Python script or an iPython workbook) would be:
Typical control flow for UseCase processing would be:
To create and commit transactions, we should use the Unit of Work pattern. That will come later.
Yes this does sound good but in order to implement such a workflow we should have the concept of an application like in celery, flask... this should make things standardized.
Very true. I am trying to keep the framework stateless/application-free - let's see how long we can persist 😄 We will need to go the application route eventually, I guess.
RepositoryFactory should prepare adapter objects and establish connections just in time so that connections are kept open only for the necessary duration. Connections are let go after processing the request.
We should initialize a unit of work at the beginning of a request, retrieve repository objects with valid current connections, process the transaction, and commit the unit of work while letting go of active connections.