The storage service contains pervasive calls to filesystem APIs (os, sys, shutil) and database APIs (Django models, Elasticsearch). If classes like package.py::Package explicitly declared dependencies on objects (say fs or db) and the APIs they required, then those dependencies could more easily be swapped out in different environments, e.g., during testing or when digital objects are accessed not from a Unix filesystem but from an S3 store.
One immediate benefit of such a refactoring would be that unit and functional tests could be made to run much more quickly. If instead of creating test databases and test directory structures we swapped in mock dependencies, the runtime of these tests could probably be significantly decreased.
The metsrw PR 27 illustrates a strategy for dependency injection that might be applicable here.
Relatedly, this strategy could allow us to clean up the space-related code and make spaces pluggable dependencies, which could allow users to avoid installing unneeded third party dependencies for space types that they never use.
The storage service contains pervasive calls to filesystem APIs (
os
,sys
,shutil
) and database APIs (Djangomodels
, Elasticsearch). If classes likepackage.py::Package
explicitly declared dependencies on objects (sayfs
ordb
) and the APIs they required, then those dependencies could more easily be swapped out in different environments, e.g., during testing or when digital objects are accessed not from a Unix filesystem but from an S3 store.One immediate benefit of such a refactoring would be that unit and functional tests could be made to run much more quickly. If instead of creating test databases and test directory structures we swapped in mock dependencies, the runtime of these tests could probably be significantly decreased.
The metsrw PR 27 illustrates a strategy for dependency injection that might be applicable here.
Relatedly, this strategy could allow us to clean up the space-related code and make spaces pluggable dependencies, which could allow users to avoid installing unneeded third party dependencies for space types that they never use.
Refactoring SS to include dependency injection could proceed via the StranglerApplication approach/pattern.