Optional Postgrex-backed range store using 1 MiB bytea chunks.
Pack and index chunks are immutable rows keyed by
(pack_id, artifact, chunk_index). A singleton manifest row carries both
the publisher generation column and the JSON manifest. publish/3 inserts
all missing chunks and updates the manifest in one database transaction, so
readers observe the previous generation or the complete new one.
Postgrex is an optional Gitility dependency. Applications that use this
backend must include {:postgrex, "~> 0.22.4"}; calls return the explicit
:postgrex_not_available error when it was omitted.
{:ok, supervisor} =
Gitility.ODB.PackFetch.start_link(
backend: {Gitility.ODB.RangeBackend.Postgres,
[url: System.fetch_env!("DATABASE_URL")]},
into: {:dir, "/var/cache/gitility"}
)init/1 accepts connection: pid or Postgrex connection options such as
url:. A pid is treated as an existing supervised pool and is never
stopped by this backend. URL/options make init/1 call
Postgrex.start_link/1; that pool is owned and stopped by terminate/2,
but because backend init runs in the PackFetch.start_link/1 caller it is
linked to that caller rather than the provider tree. Production callers
should therefore start Postgrex under their own supervisor and pass its
name or pid (a pid today); URL/options are a convenience for scripts and
tests. The optional prefix: (default "gitility_pack") is restricted to
SQL identifier characters. publish/3 takes a repository, either a pid,
URL, or Postgrex options, and backend options such as prefix:.
Summary
Functions
Publishes a local repository into PostgreSQL.
Functions
Publishes a local repository into PostgreSQL.
connection may be a Postgrex connection pid, a database URL, or Postgrex
start options. opts currently accepts prefix:. A temporary local
directory is used only by this explicit publisher to normalize loose-only
repositories into ordinary pack/index files.