feat: move report artifacts to OSS storage

This commit is contained in:
Wyndham ARR
2026-08-04 12:37:26 +08:00
parent 727643f1f2
commit a2b86cdf10
45 changed files with 1288 additions and 1417 deletions

View File

@@ -29,11 +29,18 @@ class ProcessingInputRuntime:
self.oss_client.close()
def compose_programmatic_processing(
*,
project_root: Path,
connect: Optional[Callable[[str], Any]] = None,
) -> ProcessingInputRuntime:
@dataclass
class ObjectStoreRuntime:
"""Shared OSS/object-store runtime for report publishers and downloads."""
oss_client: AliyunOssV2Client
object_store: ManagedObjectStore
def close(self) -> None:
self.oss_client.close()
def compose_object_store() -> ObjectStoreRuntime:
oss_client = AliyunOssV2Client(AliyunOssConfig.from_environment())
try:
oss_client.assert_immutable_writes_supported()
@@ -41,6 +48,24 @@ def compose_programmatic_processing(
CloudObjectBackend(oss_client),
ObjectKeyPolicy(os.environ.get("ARR_OBJECT_PREFIX", "arr")),
)
return ObjectStoreRuntime(oss_client, object_store)
except Exception:
try:
oss_client.close()
except Exception:
pass
raise
def compose_programmatic_processing(
*,
project_root: Path,
connect: Optional[Callable[[str], Any]] = None,
) -> ProcessingInputRuntime:
storage = compose_object_store()
try:
oss_client = storage.oss_client
object_store = storage.object_store
database_config = (
DatabaseConfig("controlled")
if connect is not None
@@ -64,10 +89,7 @@ def compose_programmatic_processing(
)
return ProcessingInputRuntime(coordinator, oss_client, object_store)
except Exception:
try:
oss_client.close()
except Exception:
pass
storage.close()
raise