AgentSessionManager.Ports.ArtifactStore behaviour (AgentSessionManager v0.8.0)

Copy Markdown View Source

Port (interface) for storing large blobs (patches, snapshot manifests).

This behaviour defines the contract for artifact storage backends. Artifacts are referenced by string keys and contain binary data.

Design Principles

  • Key-value semantics: Simple put/get/delete by string key
  • Binary payloads: Artifacts are opaque binary data
  • Idempotent writes: Putting the same key twice overwrites safely
  • Pluggable backends: File-based, S3, etc.

Usage

{:ok, store} = FileArtifactStore.start_link(root: "/tmp/artifacts")
:ok = ArtifactStore.put(store, "patch-abc123", patch_data)
{:ok, data} = ArtifactStore.get(store, "patch-abc123")
:ok = ArtifactStore.delete(store, "patch-abc123")

Summary

Callbacks

Deletes the artifact stored under the given key.

Retrieves binary data stored under the given key.

Stores binary data under the given key.

Functions

Deletes the artifact stored under the given key.

Retrieves binary data stored under the given key.

Stores binary data under the given key.

Types

key()

@type key() :: String.t()

store()

@type store() :: GenServer.server() | pid() | atom()

Callbacks

delete(store, key, keyword)

@callback delete(store(), key(), keyword()) ::
  :ok | {:error, AgentSessionManager.Core.Error.t()}

Deletes the artifact stored under the given key.

Idempotent - deleting a non-existent key returns :ok.

Returns

  • :ok on success
  • {:error, Error.t()} on failure

get(store, key, keyword)

@callback get(store(), key(), keyword()) ::
  {:ok, binary()} | {:error, AgentSessionManager.Core.Error.t()}

Retrieves binary data stored under the given key.

Returns

  • {:ok, binary()} on success
  • {:error, Error.t()} when key not found or read fails

put(store, key, iodata, keyword)

@callback put(store(), key(), iodata(), keyword()) ::
  :ok | {:error, AgentSessionManager.Core.Error.t()}

Stores binary data under the given key.

Overwrites any existing data for the same key.

Returns

  • :ok on success
  • {:error, Error.t()} on failure

Functions

delete(store, key, opts \\ [])

@spec delete(store(), key(), keyword()) ::
  :ok | {:error, AgentSessionManager.Core.Error.t()}

Deletes the artifact stored under the given key.

get(store, key, opts \\ [])

@spec get(store(), key(), keyword()) ::
  {:ok, binary()} | {:error, AgentSessionManager.Core.Error.t()}

Retrieves binary data stored under the given key.

put(store, key, data, opts \\ [])

@spec put(store(), key(), iodata(), keyword()) ::
  :ok | {:error, AgentSessionManager.Core.Error.t()}

Stores binary data under the given key.