2 releases

new 0.1.0-rc.1 Apr 16, 2024
0.1.0-rc.0 Dec 28, 2023

#4 in #executed

MIT license

67KB
1.5K SLoC

Burger

CI Crates.io Documentation License: MIT

An experimental service framework.


lib.rs:

An experimental service framework.

The Service trait is the central abstraction. It is an asynchronous function, accepting a request and returning a response, which can only be executed after a permit is acquired.

The root exports Service constructors, and an extension trait, ServiceExt containing combinators to modify a Service. Both the combinators and constructors each have an associated module containing related documentation, traits, and types.

Example

use burger::*;

let svc = service_fn(|x| async move {
    sleep(Duration::from_secs(1)).await;
    2 * x
})
.map(|x| x + 3)
.concurrency_limit(1)
.buffer(3)
.load_shed();
let response = svc.oneshot(30).await;
assert_eq!(Ok(63), response);

Usage

A typical Service will consist of distinct layers, each providing specific dynamics. The following flowchart attempts to categorize the exports of this crate:

 
<script type="module"> import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs'; let config = { theme: "dark", startOnLoad: true, flowchart: { useMaxWidth: true, htmlLabels: true } }; mermaid.initialize(config); </script>

Dependencies

~4–6MB
~102K SLoC