feat(storage): add ArtifactStore interface

This commit is contained in:
hsiegeln
2026-04-27 14:43:24 +02:00
parent 435153da6f
commit cddf056925

View File

@@ -0,0 +1,35 @@
package com.cameleer.server.core.storage;
import java.io.IOException;
import java.io.InputStream;
/**
* Storage abstraction for deployable JAR artifacts. Implementations decide where
* the bytes live (filesystem today; OCI registry / S3 later — see Zot follow-up
* issue #158). Callers never construct filesystem paths themselves.
*
* <p>The interface is intentionally narrow: enough to upload, fetch, and delete.
* {@link #locator} returns a stable identifier written into
* {@code app_versions.jar_path} so existing rows still resolve.
*/
public interface ArtifactStore {
/** Persist {@code bytes} of {@code size} bytes under {@code coords}. Idempotent
* on identical content; overwrites on same coords with different content.
* Returns the locator (same as {@link #locator}) for convenience. */
String put(ArtifactCoordinates coords, InputStream bytes, long size) throws IOException;
/** Open the artifact for reading. Caller closes. */
InputStream get(ArtifactCoordinates coords) throws IOException;
boolean exists(ArtifactCoordinates coords);
/** Remove the artifact and any backend-specific scaffolding (empty parent dirs, etc.).
* Silently no-ops if the artifact is already absent. */
void delete(ArtifactCoordinates coords) throws IOException;
/** Stable identifier for this storage location — written into
* {@code app_versions.jar_path} so existing rows still resolve. For the
* filesystem store this is the absolute path; for OCI it's the ref. */
String locator(ArtifactCoordinates coords);
}