Skip to main content

Config

Struct Config 

Source
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: PathBuf

Directory where index databases live. One <index_id>.db per index.

§keys_file: PathBuf

Legacy 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: PathBuf

File metering records are appended to, one JSON object per line.

§bind: SocketAddr

Address 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

Source

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.

Source

pub fn index_db_path(&self, index_id: &str) -> PathBuf

Database path for one index id.

Source

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).

Source

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.

Source

pub fn keys_db_path(&self) -> PathBuf

Path of the runtime key store inside the data dir.

Source

pub fn tenancy_db_path(&self) -> PathBuf

Path of the tenancy store inside the data dir.

Source

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§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more