#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.host: StringThe 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: DurationThe wall-clock budget of a request before it is answered pending (default 1 s).
pool_size: usizeThe blocking pool’s size: the concurrency limit (default 32).
batch_max: usizeThe most cells in one POST /cells (default 1,000).
slice_page: usizeThe default JSON page of GET /slice (default 1,000; at most 10,000 with limit=).
slice_max: usizeThe most members one slice read serves (default 1,048,576).
explain_depth: usizeThe depth of GET /explain by default (default 4; at most 16 with depth=).
max_jobs: usizeThe most jobs held at once, running or done (default 10,000).
rate: RateLimitsRate limits.
ttl: TtlsCache lifetimes.
trust_proxy: boolTake the client IP from the last X-Forwarded-For entry (behind Caddy) instead of
the peer address (default false).
cross_mesh: boolResolve 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: DurationThe 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: PolicyLicence and payment rules.
catalog: BTreeMap<String, String>Descriptions of the functions GET /find searches (name -> description).
api_keys: ApiKeysAPI keys (Authorization: Bearer dm_...).
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_base_url(self, url: impl Into<String>) -> Config
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.
Sourcepub fn from_env() -> Result<Config, ConfigError>
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.
Sourcepub fn from_vars(
get: impl Fn(&str) -> Option<String>,
) -> Result<Config, ConfigError>
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.
Sourcepub fn check(&self) -> Result<(), ConfigError>
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.
Sourcepub fn origin(&self) -> String
pub fn origin(&self) -> String
https://<host>: where this mesh is served, the base of the URLs in its envelopes.
Sourcepub fn mesh_document_base(&self) -> String
pub fn mesh_document_base(&self) -> String
The base of the URLs in the mesh document: the base URL when set, else
Config::origin.