Service-Oriented Design Patterns for Rust

Related tags

Command-line sod
Overview

SOD: Service-Oriented Design

Overview

This crate provides Service, MutService, and AsyncService traits and associated utilities to facilitiate service-oriented design. These traits and tools in this library provide concrete guidelines to help make a service-oriented design successful.

In the context of this crate, a service is simply a trait that accepts an input and produces a result. Traits can be composed or chained together using the ServiceChain found in this crate.

This crate in and of itself does not provide mechanisms to expose services on a network or facilitiate service discovery. Those implementation details are to be provided in sod-* crates, which will often simply encapsulate other open source libraries to expose them as services. Instead, this crate provides the core mechanisms to define services and in a way that helps guarantee they will be interoperable with one another at a library level.

Example

use sod::{Service, ServiceChain};

// define a service, which adds a constant number to the input, producing the result as output
struct AddService {
    n: usize,
}
impl AddService {
    pub fn new(n: usize) -> Self {
        Self { n }
    }
}
impl Service<usize> for AddService {
    type Output = usize;
    type Error = ();
    fn process(&self, input: usize) -> Result<usize, ()> {
        Ok(input + self.n)
    }
}

// chain together multiple add services, where each service's output is processed as the next service's input
let chain = ServiceChain::start(AddService::new(1))
    .next(AddService::new(2))
    .next(AddService::new(4))
    .end();

// pass 100 to the service chain, which should result in `100 + 1 + 2 + 4 = 107`
let result = chain.process(100).unwrap();
assert_eq!(107, result);
You might also like...
ratlab is a programming platform designed loosely for hobbyist and masochist to analyse and design stuff and things that transform our world?
ratlab is a programming platform designed loosely for hobbyist and masochist to analyse and design stuff and things that transform our world?

ratlab A programming language developed by Quinn Horton and Jay Hunter. ratlab is a programming platform designed loosely for hobbyists and masochists

Bracket QOS - a Quality of Service/Experience server system writtin in Rust. Derived from the excellent LibreQOS Project.

Bracket QOS - Open Source Edition This project is based on the excellent LibreQOS project. It is hoped that this can be useful for the upstream projec

Conference Monitoring Project based on Image Recognition that uses Rust Language and AWS Rekognition service to get the level of image similarity.

Conference Monitoring System based on Image Recognition in Rust This is a Conference Monitoring Project based on Image Recognition that uses Rust Lang

Infino - Fast and scalable service to store time series and logs - written in Rust

Infino ใ€ฝ๏ธ ๐Ÿชต โ€” ๐Ÿ” ๐Ÿ“Š โ€” โš–๏ธ ๐Ÿ’ฐ Ingest Metrics and Logs โ€” Query and Insights โ€” Scale and Save $$ Infino is an observability platform for storing metrics

Backend service to build customer facing dashboards 10x faster. Written in Rust.
Backend service to build customer facing dashboards 10x faster. Written in Rust.

Frolic is an open source backend service (written in Rust) to build customer facing dashboards 10x faster. You can directly connect your database to t

Authentication and authorization service, written in Rust

auth-rs auth-rs provides a simple authentication and authorization service for use in other services. The service is written in Rust and uses the acti

policy-driven signing service

SigningService (maybe we'll have a more clever name one day!) What is this? This repo has a little "serverless" (runs on lambda and some other service

Galileo OSNMA (Open Service Navigation Message Authentication)

galileo-osnma galileo-osnma is a Rust implementation of the Galileo OSNMA (Open Service Navigation Message Authentication) protocol. This protocol is

๐Ÿ“ธ website screenshots as a service
๐Ÿ“ธ website screenshots as a service

website-screenshot ๐Ÿ“ธ website screenshots as a service Features ๐Ÿ’ซ powered by Rust ๐Ÿš€ blazing fast ๐Ÿ‘ฎ โ€โ€ built-in ratelimiter ๐Ÿ‘œ built-in storage prov

Owner
Eric Thill
Eric Thill
A parser and matcher for route patterns in Rust ๐Ÿฆ€

Route Pattern A parser and matcher for a popular way to create route patterns. Patterns like these that include regular expressions, delimited in this

Dotan J. Nahum 3 Nov 24, 2022
A creator library for procedural 2D noises and patterns in Rust.

A curated list of common 2D noises and patterns in computer graphics. Mostly taken from implementations on Shadertoy. All implementations are under th

Markus Moenig 3 Nov 14, 2022
Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. A tokei/scc/cloc alternative.

tcount (pronounced "tee-count") Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. Quick Start Simply run tcount

Adam P. Regasz-Rethy 48 Dec 7, 2022
Shellfirm - Intercept any risky patterns (default or defined by you) and prompt you a small challenge for double verification

shellfirm Opppppsss you did it again? ?? ?? ?? Protect yourself from yourself! rm -rf * git reset --hard before saving? kubectl delete ns which going

elad 652 Dec 29, 2022
Game of life rendered in your terminal with over 500+ unique patterns to choose from.

Controls a: play animation n: next generation s: stop j or down arrow: go down next pattern (note: you have to stop the animation to browse the patter

Omar Magdy 20 Dec 22, 2022
List key patterns of a JSON file for jq.

jqk jqk lists key patterns of a JSON file for jq. Why? jq is a useful command line tool to filter values from a JSON file quickly on a terminal; howev

Kentaro Wada 8 Jun 25, 2023
Extract patterns from unstructured log messages

logu logu is for extracting patterns from (streaming) unstructured log messages. For parsing unstructured logs, it uses the parser from Drain. In simp

null 78 Oct 21, 2024
Zellij is a workspace aimed at developers, ops-oriented people and anyone who loves the terminal

Zellij is a workspace aimed at developers, ops-oriented people and anyone who loves the terminal. At its core, it is a terminal multiplexer (similar to tmux and screen), but this is merely its infrastructure layer.

null 9.3k Jan 4, 2023
Desktop app for reading and downloading manga. With clean distraction-free design and no clutter

Tonbun Tonbun is a desktop app for reading and downloading manga. With clean distraction-free design and no clutter. Build with Rust, Tauri, Vue.js, a

null 23 Nov 30, 2022
Designed as successor to Pretty-Good-Video for improved codec structure, API design & performance

Pretty Fast Video Minimal video codec designed as a successor to Pretty Good Video Goals are to improve: Quality API design Codec structure (Hopefully

Hazel Stagner 36 Jun 5, 2023