Gitility.ObjectStore.S3 (Gitility v0.5.0)

Copy Markdown View Source

S3-compatible object store with conditional, single-object writes.

Req is optional. Applications using this adapter add it explicitly:

{:req, "~> 0.5.8"}

The adapter uses Req's AWS Signature Version 4 step and invokes a zero-arity credential provider for every request. A provider returns a map with non-empty :access_key_id and :secret_access_key binaries and an optional binary :session_token. Provider failures are sanitised to :credentials_unavailable; credentials and signed requests are never kept in adapter state or returned in errors.

AWS uses virtual-host addressing by default. Most MinIO, Tigris, and R2 endpoints use path addressing:

Gitility.ObjectStore.S3.init(
  bucket: "mirrors",
  region: "auto",
  endpoint_url: "https://objects.example.com",
  addressing: :path,
  credentials: fn -> credentials_from_my_vault() end
)

The endpoint accepts only a scheme and host with an optional port. Redirects and retries are disabled. Correct publication requires a provider that implements conditional If-Match and If-None-Match writes; AWS S3, MinIO, R2, and Tigris provide that capability.

PUT uses one streamed request and is limited to S3's 5 GiB single-PUT maximum. Multipart upload is not implemented.

Summary

Types

t()

@type t() :: %Gitility.ObjectStore.S3{
  addressing: :virtual_host | :path,
  bucket: binary(),
  credentials_fun: (-> map()),
  finch: atom(),
  host: binary(),
  port: :inet.port_number() | nil,
  region: binary(),
  scheme: binary()
}