Add public repository interfaces and subclassable adapter CRUD API.
Define split JSON and object repository ABCs, promote adapter methods to public CRUD, add example domain repositories, modernize interface stubs, and make the package installable for tests. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
co-authored by
Cursor
parent
f4280f15c1
commit
e98fd3b90d
@@ -0,0 +1,23 @@
|
||||
"""Example domain repository backed by MinIO objects."""
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
from python_repositories.adapters.minio_adapter import MinioAdapter
|
||||
|
||||
|
||||
class ArtifactObjectRepository(MinioAdapter):
|
||||
"""Example: domain repository backed by MinIO objects."""
|
||||
|
||||
def _object_name(self, artifact_id: str) -> str:
|
||||
return f"artifacts/{artifact_id}"
|
||||
|
||||
def get_artifact(self, artifact_id: str) -> BytesIO | None:
|
||||
return self.get(self._object_name(artifact_id))
|
||||
|
||||
def store_artifact(
|
||||
self,
|
||||
artifact_id: str,
|
||||
data: BytesIO,
|
||||
content_type: str = "application/octet-stream",
|
||||
) -> None:
|
||||
self.put(self._object_name(artifact_id), data, content_type)
|
||||
Reference in New Issue
Block a user