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 ;
// define a service, which adds a constant number to the input, producing the result as output
// chain together multiple add services, where each service's output is processed as the next service's input
let chain = start
.next
.next
.end;
// pass 100 to the service chain, which should result in `100 + 1 + 2 + 4 = 107`
let result = chain.process.unwrap;
assert_eq!;