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