Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config {
Show 21 fields pub host: String, pub base_url: Option<String>, pub namespaces: Vec<String>, pub budget: Duration, pub pool_size: usize, pub batch_max: usize, pub slice_page: usize, pub slice_max: usize, pub explain_depth: usize, pub max_jobs: usize, pub rate: RateLimits, pub ttl: Ttls, pub trust_proxy: bool, pub cross_mesh: bool, pub cross_mesh_hosts: Option<Vec<String>>, pub peers: BTreeMap<String, String>, pub peer_timeout: Duration, pub aliases: BTreeMap<String, String>, pub policy: Policy, pub catalog: BTreeMap<String, String>, pub api_keys: ApiKeys,
}
Expand description

The mesh’s configuration.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§host: String

The DNS name the mesh signs as (computed_by) and serves on: https://<host>/... (e.g. mesh-test.datumesh.com), unless Config::base_url says otherwise.

§base_url: Option<String>

Where the mesh is served when not at https://<host>, e.g. http://127.0.0.1:8787 for a mesh on this machine (default: none): the base of every URL in the mesh document (bindings and the endpoints, crate::Mesh::mesh_document). https:// with any host; http:// only when the mesh’s host is unrooted (its last label is invalid, SPEC 2.5, e.g. local.invalid) and only with 127.0.0.1, [::1] or localhost; an optional port; no path, query, fragment or trailing slash (check_base_url; crate::MeshBuilder::build refuses another with crate::BuildError::BaseUrl).

An http:// mesh document is for local use only: it is not valid under spec-0.4.3 (9.6 wants https:// URLs on the host), and core 0.3.6’s resolve_mesh refuses it. spec-0.4.4 will allow exactly this: for an unrooted host, mesh-document URLs and poll may be http:// on a loopback address only (127.0.0.1, [::1], localhost); rooted hosts stay https://-only. datumesh-core 0.3.8 will accept it. The key document and host do not change, nor do the URLs in envelopes and headers (a pending envelope’s poll, a page’s next, the canonical link), which stay Config::origin: SPEC 5.5 makes poll an https:// URL, and a client maps https://<host>/ onto where it reaches the mesh (its peers).

§namespaces: Vec<String>

The hosts whose names this mesh owns (default: host). A name under any other host is resolved across meshes.

§budget: Duration

The wall-clock budget of a request before it is answered pending (default 1 s).

§pool_size: usize

The blocking pool’s size: the concurrency limit (default 32).

§batch_max: usize

The most cells in one POST /cells (default 1,000).

§slice_page: usize

The default JSON page of GET /slice (default 1,000; at most 10,000 with limit=).

§slice_max: usize

The most members one slice read serves (default 1,048,576).

§explain_depth: usize

The depth of GET /explain by default (default 4; at most 16 with depth=).

§max_jobs: usize

The most jobs held at once, running or done (default 10,000).

§rate: RateLimits

Rate limits.

§ttl: Ttls

Cache lifetimes.

§trust_proxy: bool

Take the client IP from the last X-Forwarded-For entry (behind Caddy) instead of the peer address (default false).

§cross_mesh: bool

Resolve names under hosts this mesh does not own (default true).

§cross_mesh_hosts: Option<Vec<String>>

When set, the only other hosts whose names are resolved across meshes; names under any other host are not served (not_covered). Default: every host.

§peers: BTreeMap<String, String>

Origins to use instead of https://<host> for some hosts, e.g. mesh-b.example -> http://127.0.0.1:8081 (tests and private networks only; the default is none).

§peer_timeout: Duration

The time limit of one request to another mesh (default 10 s; SPEC 9.3’s bound).

§aliases: BTreeMap<String, String>

Short names of the call syntax: @alias -> fully qualified name.

§policy: Policy

Licence and payment rules.

§catalog: BTreeMap<String, String>

Descriptions of the functions GET /find searches (name -> description).

§api_keys: ApiKeys

API keys (Authorization: Bearer dm_...).

Implementations§

Source§

impl Config

Source

pub fn new(host: impl Into<String>) -> Config

The defaults for a mesh signing as host.

Source

pub fn with_base_url(self, url: impl Into<String>) -> Config

The configuration with this base URL (Config::base_url); it is checked when the mesh is built.

Source

pub fn from_env() -> Result<Config, ConfigError>

The configuration from the environment (DATUMESH_*; the README lists them). The files named (DATUMESH_API_KEYS_FILE, and the others) are read here; the API keys file must have mode 0600.

Source

pub fn from_vars( get: impl Fn(&str) -> Option<String>, ) -> Result<Config, ConfigError>

The configuration from variables get answers, as Config::from_env reads them.

Source

pub fn check(&self) -> Result<(), ConfigError>

Checks the configuration: names are DNS names and function names, the base URL is one (check_base_url), numbers in range.

Source

pub fn owns(&self, host: &str) -> bool

Whether this mesh owns the names under host.

Source

pub fn origin(&self) -> String

https://<host>: where this mesh is served, the base of the URLs in its envelopes.

Source

pub fn mesh_document_base(&self) -> String

The base of the URLs in the mesh document: the base URL when set, else Config::origin.

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

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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