mise_server/lib.rs
1//! # `mise-server`
2//!
3//! mise (MIcro SErvice) also pronounced as 'mice' is a web stack for the
4//! specific use in micro services.
5//!
6//! See [prelude::Mise].
7//!
8//! ## Server
9//!
10//! The micro service environment is the kind of setup where each service is
11//! relatively small and with minimal overheads since they have to talk to each
12//! other a lot. A micro service is not directly exposed to the public.
13//! A typical setup would be pods in kubernetes or a similar infrastructure.
14//!
15//! The typical use of micro services are for RPC, where a user is not involved
16//! and every request is seen as an api call.
17//!
18//! Since this implementation uses no async, the microservice being built would
19//! be of a particular kind, usually without any IO wait on the downstream or
20//! coded with that in mind to be non blocking by the user of this stack.
21//!
22//! Since the environment is meant to be also micro, the requests are handled
23//! in a monothreaded way, and so enqueued as soon as a request object is
24//! available, a call for a response is made. There will be a second thread for
25//! piping the channels in and out of the IO.
26//!
27//! ## Routing
28//!
29//! Basic routing is available.
30//!
31//! - static routes `/route`
32//! - query params `/route?id=X`
33//! - last path item wildcard `/route/*` for `/route/X`
34//!
35//! ## Metrics
36//!
37//! Metrics are being measured with [metrics](https://docs.rs/metrics) but the
38//! registry is not initialized by default, that will have to be done by the
39//! user of the library by setting up the crate that will implement the
40//! metric endpoint (Eg
41//! [metrics-exporter-prometheus](https://docs.rs/metrics-exporter-prometheus))
42//! before starting the server.
43//!
44//! ## Tracing
45//!
46//! Logs are done through the [tracing](https://docs.rs/tracing) crate, and can
47//! be setup by the user through calling the
48//! [tracing_subscriber](https://docs.rs/tracing_subscriber) crate.
49//!
50//! ## Limitations
51//!
52//! - HTTP 1 only: http2 has the issue of sticky sessions for its nature of
53//! keeping the connection open. Http 1 is easier to distribute across more
54//! nodes because connections are usually created in a pool from the point of
55//! view of the clients. Uses [http](https://docs.rs/http) for basic types.
56//!
57//! - No TLS: it is assumed the local network where microservices are running
58//! to be already protected. TLS would be an unnecessary complexity for
59//! internal use, add too many dependencies, and too hard to setup for non
60//! blocking sockets.
61//!
62//! - No async: non-blocking IO is managed through this library APIs directly
63//! and the use of channels. Uses [mio](https://docs.rs/mio)
64//!
65//! - JSON only: common support is JSON only in microservices. Uses
66//! [serde_json](https://docs.rs/serde_json)
67//!
68//! - No compression: intented to be in a local network where speeds of
69//! transfer do not significantly require compression and the waste of cpu
70//! that implies. If the response is wihtin MTU, there is even less sense to
71//! compress, and this library is not meant to respond with files or
72//! attachments, but a RPC JSON response.
73//!
74//! - No 3xx redirects: the server is meant to respond directly to a RPC and
75//! does not forward the request anywhere else.
76//!
77//! - Auth optional: Authentication header is optionally implemented but it is
78//! going to be handled by the user on the server side.
79//!
80//! - No relative URI: No '..' interpreted. This is an RPC stack and requires
81//! specific paths. No file system path is mapped through URIs.
82
83mod connection;
84mod mise;
85mod routes;
86mod server;
87
88pub mod prelude {
89 pub use super::mise::{
90 Deserializable, Mise, Request, Response, Route, Serializable, TextRoute,
91 };
92 pub use http::StatusCode;
93}