SuperPi.Artifacts.Store behaviour (super_pi v0.1.0)

Copy Markdown View Source

Backend contract for SuperPi.Artifacts. Validation (name, size) happens before a call, so a backend only stores and fetches. Implement it for another store, such as an S3-compatible bucket.

Summary

Callbacks

delete(conversation_id, name)

@callback delete(conversation_id :: integer(), name :: String.t()) ::
  :ok | {:error, term()}

get(conversation_id, name)

@callback get(conversation_id :: integer(), name :: String.t()) ::
  {:ok, %{data: binary(), content_type: String.t(), size: non_neg_integer()}}
  | {:error, :not_found | term()}

list(conversation_id)

@callback list(conversation_id :: integer()) :: [
  %{name: String.t(), size: non_neg_integer(), content_type: String.t()}
]

put(conversation_id, name, data, content_type)

@callback put(
  conversation_id :: integer(),
  name :: String.t(),
  data :: binary(),
  content_type :: String.t()
) :: {:ok, %{name: String.t(), size: non_neg_integer()}} | {:error, term()}