moonzero · control plane v0.15.0 · 49 packages · 4 targets · Apache-2.0 docs / control / restconf GitHub

04 / CONTROL

restconf

Which built-in layers the engine installs (MiddlewaresConf), every flag on by default, so an etc/*.yaml that says nothing about middleware still gets the whole chain.

struct MiddlewaresConf

struct

fn MiddlewaresConf::new( trace~ : Bool = true, log~ : Bool = true, prometheus~ : Bool = true, max_conns~ : Bool = true, breaker~ : Bool = true, shedding~ : Bool = true, timeout~ : Bool = true, recover~ : Bool = true, metrics~ : Bool = true, max_bytes~ : Bool = true, gunzip~ : Bool = true) -> MiddlewaresConf

fnThe full chain, which is what defaults to.

struct PrivateKeyConf

struct

struct SignatureConf

struct

fn SignatureConf::new( strict~ : Bool = false, expiry_ms~ : Int64 = 3600000L, private_keys~ : Array[PrivateKeyConf] = []) -> SignatureConf

fnSignature settings that verify nothing: not strict, one-hour expiry, no keys.

struct RestConf

structA REST service's configuration, embedding ServiceConf the way does. The name, bind address and request timeout live on that embedded config — host(), port() and timeout_ms() read them — and everything else here is RestConf's own. max_bytes is an Int where uses int64: it is compared against a request's Content-Length, and its own range= tag caps it at 32 MiB.

fn RestConf::new( service~ : ServiceConf = ServiceConf::new(), cert_file~ : String = "", key_file~ : String = "", verbose~ : Bool = false, max_conns~ : Int32 = 10000, max_bytes~ : Int32 = 1048576, cpu_threshold~ : Int64 = 900L, signature~ : SignatureConf = SignatureConf::new(), middlewares~ : MiddlewaresConf = MiddlewaresConf::new(), trace_ignore_paths~ : Array[String] = []) -> RestConf

fnA REST config with defaults: no TLS, not verbose, 10000 connections, a 1 MiB body cap, a 90% CPU shed threshold, and the full middleware chain.

fn RestConf::host(self : RestConf) -> String

fnThe address the service binds.

fn RestConf::port(self : RestConf) -> Int32

fnThe port the service binds.

fn RestConf::timeout_ms(self : RestConf) -> Int32

fnThe per-request timeout budget in milliseconds; 0 disables it.

fn RestConf::tls(self : RestConf) -> Bool

fnWhether a certificate and its key are both named. This library assembles an application, not a socket: the object it builds is handed to a host, and the host is what terminates TLS. These two paths are carried here so that host reads them from the same document as everything else — and a document that names only one of them is refused at load rather than leaving the service listening in the clear while its operator believes otherwise.

fn RestConf::from_yaml(src : String) -> RestConf raise Refused

fnLoad a RestConf from the YAML ships as etc/*.yaml. Keys are matched canonically, MOONZERO_* env variables override the file, and a value outside its options=/range= constraint is an error. Name and Port carry no default, exactly as in the reference: a rest service that does not say who it is or where to listen fails to load.

fn RestConf::from_json(src : String) -> RestConf raise Refused

fnLoad a RestConf from a JSON config string, with the same semantics as from_yaml.

extend MiddlewaresConf with Debug::

item

extend MiddlewaresConf with Eq::

item

extend PrivateKeyConf with Debug::

item

extend PrivateKeyConf with Eq::

item

extend SignatureConf with Debug::

item

extend SignatureConf with Eq::

item