pub struct RepoCatalog { /* private fields */ }Expand description
Create, open, list and delete repositories.
Cheap to clone; every clone reads and writes the same document.
Implementations§
Source§impl RepoCatalog
impl RepoCatalog
Sourcepub fn new(store: Arc<dyn ControlStore>) -> Result<Self>
pub fn new(store: Arc<dyn ControlStore>) -> Result<Self>
Open the catalog held in store (the certificate-identity plan).
This is the control store: the server’s own, not a repository’s.
Sourcepub fn history(&self) -> Result<Vec<DocVersion>>
pub fn history(&self) -> Result<Vec<DocVersion>>
Every version this catalog has ever had, oldest first (the certificate-identity plan). See
crate::AuthTable::history.
Sourcepub fn create_namespace(&self, name: &str) -> Result<Namespace>
pub fn create_namespace(&self, name: &str) -> Result<Namespace>
Create a namespace.
Nested names (team/sub) are allowed and every level is validated by
the sandbox’s component rules, so a namespace can never be a path
escape.
Sourcepub fn set_namespace_explode_budget(
&self,
name: &str,
bytes: Option<u64>,
) -> Result<Namespace>
pub fn set_namespace_explode_budget( &self, name: &str, bytes: Option<u64>, ) -> Result<Namespace>
Set (or clear) an account’s exploded-cache quota.
None puts the namespace back on the server’s default; Some(0) is
unlimited and is a decision rather than an absence. The quota reaches a
repository the next time its store is opened, and every store already
open under this namespace immediately — see
ServerStores::apply_explode_quota.
It cannot fail a read and it cannot lose an object: the cache it bounds is re-derivable from the packs, which it does not bound. Lowering a quota below what a repository already holds evicts; it never refuses.
Sourcepub fn namespace_explode_budget(&self, name: &str) -> Result<Option<u64>>
pub fn namespace_explode_budget(&self, name: &str) -> Result<Option<u64>>
This namespace’s quota, or None for “the server’s default”. A missing
namespace is None too: a repository whose namespace row is gone is a
broken catalog, and answering “the default” is the safe reading of it.
Sourcepub fn set_namespace_public(
&self,
name: &str,
public: bool,
) -> Result<Namespace>
pub fn set_namespace_public( &self, name: &str, public: bool, ) -> Result<Namespace>
Make a namespace public, or private again (Namespace::public).
Only the stored fact: who may change it (the account admin) is the gRPC
layer’s question (Repos.SetNamespaceSettings). It touches no
repository — a private repository stays private in a public namespace.
Sourcepub fn set_namespace_events_public(
&self,
name: &str,
public: bool,
) -> Result<Namespace>
pub fn set_namespace_events_public( &self, name: &str, public: bool, ) -> Result<Namespace>
Make an account’s emitted events public, or private again
(Namespace::events_public). The stored fact only, as
RepoCatalog::set_namespace_public.
Sourcepub fn version(&self) -> Result<Option<BlobId>>
pub fn version(&self) -> Result<Option<BlobId>>
The catalog’s version: changes exactly when any namespace or repository row does. One pointer read — what lets a reader that keeps its own per-namespace index of the catalog (the server’s usage ledger) rebuild it only when something changed, instead of listing every repository on every read.
Sourcepub fn namespaces(&self) -> Result<Vec<Namespace>>
pub fn namespaces(&self) -> Result<Vec<Namespace>>
Every namespace, by name. O(namespaces), the listing path.
Sourcepub fn delete_namespace(
&self,
name: &str,
delete_repos: bool,
) -> Result<Vec<Repo>>
pub fn delete_namespace( &self, name: &str, delete_repos: bool, ) -> Result<Vec<Repo>>
Delete a namespace, and return the repositories that went with it.
Refuses a namespace that still holds repositories unless delete_repos.
Deleting a tenant’s repositories has to be asked for explicitly.
Sourcepub fn create(&self, spec: NewRepo) -> Result<Repo>
pub fn create(&self, spec: NewRepo) -> Result<Repo>
Create a repository.
The namespace must already exist. A repository is never allowed to conjure one, because then a typo in a push URL would silently become a tenant.
Sourcepub fn open(&self, path: &RepoRef) -> Result<Repo>
pub fn open(&self, path: &RepoRef) -> Result<Repo>
Look a repository up, failing if it is not there.
This is what the SSH layer calls after the sandbox has produced a
RepoRef: a path that parses is not a repository that exists.
Sourcepub fn get(&self, path: &RepoRef) -> Result<Option<Repo>>
pub fn get(&self, path: &RepoRef) -> Result<Option<Repo>>
Look a repository up.
This is the connection path. Control::resolve calls it for every
SSH session. One shard probe, and no object read at all once the catalog
has been read since it last changed.
Sourcepub fn get_many(&self, paths: &[RepoRef]) -> Result<Vec<Option<Repo>>>
pub fn get_many(&self, paths: &[RepoRef]) -> Result<Vec<Option<Repo>>>
Many rows, one read of the catalog (round 5.3.1): get for each
path, the document’s pointer read once rather than once per row — a
listing’s access check asks about every row it lists.
Sourcepub fn list(&self, namespace: Option<&str>) -> Result<Vec<Repo>>
pub fn list(&self, namespace: Option<&str>) -> Result<Vec<Repo>>
Every repository, or every repository in one namespace, ordered by key.
O(repositories) either way; see RepoCatalog::delete_namespace.
Sourcepub fn delete(&self, path: &RepoRef) -> Result<Repo>
pub fn delete(&self, path: &RepoRef) -> Result<Repo>
Remove a repository’s metadata and hand it back.
The caller owns the storage: whatever backend held its objects and refs is still there afterwards and must be dealt with separately.
Sourcepub fn set_default_branch(&self, path: &RepoRef, branch: &str) -> Result<Repo>
pub fn set_default_branch(&self, path: &RepoRef, branch: &str) -> Result<Repo>
Record another default branch for a repository.
This writes the catalog and nothing else. The repository’s own
HEAD is a projection of this value and is moved by
point_head_at, which whoever owns the repository’s stores calls
with the Repo this hands back. Doing it here is not possible: the
catalog holds metadata only and has never had a repository’s ref store
(see this module’s opening comment).
Sourcepub fn set_visibility(
&self,
path: &RepoRef,
visibility: Visibility,
) -> Result<Repo>
pub fn set_visibility( &self, path: &RepoRef, visibility: Visibility, ) -> Result<Repo>
Change a repository’s visibility.