pub struct Config {
pub data_dir: PathBuf,
pub keys_file: PathBuf,
pub metering_log: PathBuf,
pub bind: SocketAddr,
pub index_ttl_secs: Option<u64>,
pub deny_ownerless_indexes: Option<bool>,
}Expand description
Resolved paths and bind address for one server process.
Fields§
§data_dir: PathBufDirectory where index databases live. One <index_id>.db per index.
keys_file: PathBufLegacy flat key_id:secret file. No longer the key store — the
store is <data_dir>/keys.db — but at startup its entries are
imported when the store holds no active key, so an existing
deployment keeps working (see crate::keys).
metering_log: PathBufFile metering records are appended to, one JSON object per line.
bind: SocketAddrAddress the HTTP server listens on.
index_ttl_secs: Option<u64>Lifetime of a newly created index, in seconds, if the operator
sets one. None means indexes do not expire.
deny_ownerless_indexes: Option<bool>The operator’s ruling on ownerless (“legacy”) indexes, from
CODETOPO_DENY_OWNERLESS_INDEXES: Some(true) always denies
them, Some(false) always allows them, and None (unset)
applies the default rule — deny when the key store holds more
than one active key, allow when it holds one (see
crate::tenancy::ownerless_readable, which owns the rule).
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Result<Self, ApiError>
pub fn from_env() -> Result<Self, ApiError>
Reads configuration from the environment, applying documented defaults.
Recognised variables: CODETOPO_DATA_DIR, CODETOPO_KEYS_FILE,
CODETOPO_METERING_LOG, CODETOPO_BIND, CODETOPO_INDEX_TTL_SECS,
CODETOPO_DENY_OWNERLESS_INDEXES.
An empty value is treated as unset so CODETOPO_BIND= behaves like an
absent variable. A TTL that is present but not a non-negative integer
is a startup error, like a bad bind address: guessing a lifetime for
customer data would be worse than refusing to boot. The ownerless
flag follows the same rule: 1/true or 0/false are accepted
and anything else is a startup error — a misread access-control
flag must not silently become the operator’s opposite intent.
Sourcepub fn index_db_path(&self, index_id: &str) -> PathBuf
pub fn index_db_path(&self, index_id: &str) -> PathBuf
Database path for one index id.
Sourcepub fn index_workdir_path(&self, index_id: &str) -> PathBuf
pub fn index_workdir_path(&self, index_id: &str) -> PathBuf
Directory holding one index’s ingested repository tree, for
indexes created from a repo_url clone or an archive upload
(paid-path S2): <data_dir>/ingest/<index_id>/. Hosted ingest
lands here — server-owned ground, never a caller-chosen path —
and the tree’s lifetime is the index’s: it is deleted with the
database when the index expires (see Config::remove_index_files).
Sourcepub fn remove_index_files(&self, index_id: &str)
pub fn remove_index_files(&self, index_id: &str)
Deletes an index’s files: its database and, if it was created by a hosted ingest, its staged repository tree.
A missing file is not an error (an index may already be half cleaned); other failures are logged, not propagated — the caller is refusing or sweeping the index either way, and a stuck file must not resurrect it. The recursive workdir removal is gated on the id being a server-generated UUID: tenancy records are only ever written for generated ids, and a caller-shaped string from a URL must never turn into a recursive delete.
Sourcepub fn keys_db_path(&self) -> PathBuf
pub fn keys_db_path(&self) -> PathBuf
Path of the runtime key store inside the data dir.
Sourcepub fn tenancy_db_path(&self) -> PathBuf
pub fn tenancy_db_path(&self) -> PathBuf
Path of the tenancy store inside the data dir.
Sourcepub async fn prepare(&self) -> Result<(KeyStore, Tenancy), ApiError>
pub async fn prepare(&self) -> Result<(KeyStore, Tenancy), ApiError>
Creates data_dir if absent and opens the runtime stores.
Key bootstrap, in order: open <data_dir>/keys.db; if it holds no
active key and the legacy keys file exists, import it. Fails closed
(Phase 2 design §4) when no active key results: starting with zero
usable keys would serve 401 for every request while looking
healthy, which is harder to diagnose than refusing to boot.
Also sweeps expired indexes: their ownership records are pruned
and their files (database plus any ingested tree) deleted, so a
data dir cannot grow on indexes nobody may read any more. The
same refusal is enforced lazily per request (see
crate::handlers).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more