Condukt.SessionStore.ObjectStore.Bucket behaviour (Condukt v3.0.0)

Copy Markdown View Source

The object storage Condukt.SessionStore.ObjectStore writes to.

A bucket is passed as {module, config}. Condukt ships Condukt.SessionStore.ObjectStore.S3, for S3 and services compatible with it such as Tigris, R2, and MinIO, and Condukt.SessionStore.ObjectStore.Memory for tests.

The store only ever creates objects, and relies on a create failing when the key already exists: that is how a writer that lost its session finds out. A bucket must therefore make create/3 atomic, as S3 does for a PutObject with If-None-Match: *, and list/3 must see every object whose create has returned.

Summary

Callbacks

Creates the object, or returns {:error, :exists} when the key already has one.

Deletes the object, succeeding when there is none.

Every key under prefix that sorts after start_after, in ascending order.

Callbacks

create(term, key, body)

@callback create(term(), key :: String.t(), body :: binary()) ::
  :ok | {:error, :exists} | {:error, term()}

Creates the object, or returns {:error, :exists} when the key already has one.

delete(term, key)

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

Deletes the object, succeeding when there is none.

get(term, key)

@callback get(term(), key :: String.t()) ::
  {:ok, binary()} | :not_found | {:error, term()}

list(term, prefix, start_after)

@callback list(term(), prefix :: String.t(), start_after :: String.t() | nil) ::
  {:ok, [String.t()]} | {:error, term()}

Every key under prefix that sorts after start_after, in ascending order.