Crate sod

Crate sod 

Source
Expand description

SOD: Service-Oriented Design

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 in a way that helps guarantee they will be interoperable with one another at a library level.

Modules§

idle
Idle functions that may optionally be used by crate::RetryService and crate::PollService.
thread

Structs§

ArcAsyncService
A Service, which encapsulates an Arc<Service<Input>>.
ArcService
A Service, which encapsulates an Arc<Service<Input>>.
AsyncServiceChainBuilder
Returned by ServiceChain::start_async to build an async service chain. Use the next(self, AsyncService) function to append more services to the ServiceChain. Use the end(self) function to finish building and return the resulting ServiceChain.
CloneService
Clone a Borrow<T> input, producing the cloned T value as output
CloningForkService
A Service, MutService, or AsyncService that encapsulates two service and accepts a Cloneable input, which is passed to both underlying services, returning their outputs as a tuple.
DynAsyncService
An AsyncService which encapsulates a Box<dyn AsyncService<...>>.
DynMutService
A MutService which encapsulates a Box<dyn MutService<...>>.
DynService
A Service which encapsulates a Box<dyn Service<...>>.
FnMutService
A Service, which encapsulates a FnMut.
FnService
A Service, which encapsulates a Fn.
IntoIterService
Iterate over Vec<T> input, passing each T to an underlying Service, returning Vec<Output>.
IntoService
A Service which can accept any input that can be Intoed an ouput, always returning Ok(output).
MaybeProcessService
A Service that processes a Option<T> as input, processing with an underlying Service<Input = T> when the input is Some, producing Option<S::Output> as output.
MutServiceChainBuilder
Returned by ServiceChain::start_mut to build a mut service chain. Use the next(self, MutService) function to append more services to the ServiceChain. Use the end(self) function to finish building and return the resulting ServiceChain.
MutexService
A Service, which encapsulates a MutService, using std::sync::Mutex to aquire mutability in each call to process.
NoOpService
A Service which no-ops, passing the input as Ok(output).
PollService
A Service, MutService, or AsyncService, which encapsulates a Service<(), Output = Option<T>>, MutService<(), Output = Option<T>>, or AsyncService<(), Output = Option<T>>, blocking with the given idle function until a value is returned or the idle function returns an error.
RefCellService
A Service, which encapsulates a MutService, using std::cell::RefCell to aquire mutability in each call to process.
RefForkService
A Service, MutService, or AsyncService that encapsulates two service and accepts a input as a reference, which is passed to both underlying services, returning their outputs as a tuple.
RetryService
A Service, MutService, or AsyncService, which encapsulates a Retryable, blocking and retrying until a value is returned, an un-retryable error is encountered, or the idle function returns an Err.
RetryToOptionService
A Service, which encapsulates a Retryable, producing None when a retryable event is encounterd.
ServiceAsync
An AsyncService that encapsulates an underlying Service, exposing it as async.
ServiceChain
A chain of Service, MutService, or AsyncService implementations, which is itself a single Service, MutService, or AsyncService that accepts the first service in the chain’s input and produces the the last service in the chain’s output. When any service in the chain returns an Err, the chain will break early, encapsulate the error in a ServiceChainError, and return Err(ServiceChainError) immediately.
ServiceChainBuilder
Returned by ServiceChain::start to build a sync service chain. Use the next(self, Service) function to append more services to the ServiceChain. Use the end(self) function to finish building and return the resulting ServiceChain.
ServiceChainError
Returned by ServiceChain when a service in the chain returns an Err Result.
ServiceMut
A MutService that encapsulates an underlying Service, exposing it as mut.
SpawnService
A Service that accepts a FnOnce() as input, which is passed to spawn(), and produces a JoinHandle as output.
StopService
A Service that will return Ok(Input) when the provided function returns true, or or Err(Stopped) when the provided function returns false.
Stopped
A generic error that indicates stoppage
TryIntoService
A Service which can accept any input that can be Intoed an ouput, returning Result<Self::Output, TryInto::Error>.

Enums§

RetryError
Used by idle and retry services to interrupt a poll or retry loop

Traits§

AsyncService
An async service trait
MutService
A mut service trait
Retryable
To be implemented by non-blocking services which may return the moved input in a resulting Err to be retried.
Service
A sync service trait

Attribute Macros§

async_trait
Provide support for async fn by exposing the external async_trait crate. See async_trait for details.