Compare commits
5
Commits
v0.2.0
..
ee6acc6791
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee6acc6791 | ||
|
|
0ca07c02ac | ||
|
|
7446e88850 | ||
|
|
d5f437f77c | ||
|
|
7beca7c398 |
@@ -1,5 +1,13 @@
|
|||||||
from .redis_adapter import RedisAdapter as RedisAdapter
|
"""
|
||||||
|
Adapters for various backend repositories (e.g., Redis, Minio).
|
||||||
|
|
||||||
|
This module exposes concrete implementations for repository interfaces.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .redis_adapter import RedisAdapter
|
||||||
|
from .minio_adapter import MinioAdapter
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"RedisAdapter",
|
"RedisAdapter",
|
||||||
|
"MinioAdapter",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,10 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import os
|
import os
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
from minio import Minio, S3Error
|
|
||||||
|
|
||||||
from python_utils import check_env
|
from python_utils import check_env
|
||||||
|
|
||||||
from python_repositories.interfaces import (
|
from python_repositories.interfaces import (
|
||||||
@@ -28,6 +25,11 @@ class MinioAdapter(
|
|||||||
chunk_size: int = 5 * 2**20 # 5 MiB
|
chunk_size: int = 5 * 2**20 # 5 MiB
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
# Import here to avoid hard dependency if MinioAdapter is not used
|
||||||
|
try:
|
||||||
|
from minio import Minio, S3Error # type: ignore[import]
|
||||||
|
except ImportError as e:
|
||||||
|
raise RuntimeError("MinioAdapter dependencies missing") from e
|
||||||
# Setup logger
|
# Setup logger
|
||||||
self.logger = structlog.get_logger(
|
self.logger = structlog.get_logger(
|
||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
|
|||||||
@@ -2,13 +2,9 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
import redis
|
|
||||||
from redis.commands.json.path import Path as RedisPath
|
|
||||||
|
|
||||||
from python_utils import check_env
|
from python_utils import check_env
|
||||||
|
|
||||||
from python_repositories.interfaces import (
|
from python_repositories.interfaces import (
|
||||||
@@ -28,6 +24,12 @@ class RedisAdapter(
|
|||||||
encoding: str = "UTF-8"
|
encoding: str = "UTF-8"
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
# Import here to avoid hard dependency to optional package
|
||||||
|
try:
|
||||||
|
import redis # type: ignore[import]
|
||||||
|
from redis.commands.json.path import Path as RedisPath # type: ignore[import]
|
||||||
|
except ImportError as e:
|
||||||
|
raise RuntimeError("RedisAdapter dependencies missing") from e
|
||||||
# Setup logger
|
# Setup logger
|
||||||
self.logger = structlog.get_logger(
|
self.logger = structlog.get_logger(
|
||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
|
|||||||
Reference in New Issue
Block a user