Behaviour that all SferaDoc PDF object-storage adapters must implement.
Object storage is the durable source of truth for rendered PDFs. Adapters
persist PDF binaries keyed by {name, version, assigns_hash} so that identical
renders survive BEAM restarts without re-invoking Chrome.
Implementing a Custom Adapter
@behaviour SferaDoc.Pdf.ObjectStore.AdapterImplement all callbacks
Return
nilfromworker_spec/0if your adapter manages its own connections externally (e.g. HTTP-based S3/Azure clients)Configure the library to use your adapter:
config :sfera_doc, :pdf_object_store, adapter: MyApp.CustomAdapter, my_option: "value"
Summary
Callbacks
Retrieves a stored PDF binary. Returns {:ok, binary} on hit, :miss if the
object does not exist, or {:error, reason} on storage failure (treated as :miss).
Persists a rendered PDF binary. Returns :ok on success or {:error, reason} on
failure. Failures are logged but do not abort the render pipeline.
Returns a child spec for processes this adapter needs, or nil if the adapter
manages its own connections (e.g. HTTP-based clients).
Types
@type assigns_hash() :: String.t()
@type name() :: String.t()
@type reason() :: any()
@type version() :: pos_integer()
Callbacks
@callback get(name(), version(), assigns_hash()) :: {:ok, binary()} | :miss | {:error, reason()}
Retrieves a stored PDF binary. Returns {:ok, binary} on hit, :miss if the
object does not exist, or {:error, reason} on storage failure (treated as :miss).
@callback put(name(), version(), assigns_hash(), binary()) :: :ok | {:error, reason()}
Persists a rendered PDF binary. Returns :ok on success or {:error, reason} on
failure. Failures are logged but do not abort the render pipeline.
@callback worker_spec() :: Supervisor.child_spec() | nil
Returns a child spec for processes this adapter needs, or nil if the adapter
manages its own connections (e.g. HTTP-based clients).