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::RetryServiceandcrate::PollService. - thread
Structs§
- ArcAsync
Service - A
Service, which encapsulates anArc<Service<Input>>. - ArcService
- A
Service, which encapsulates anArc<Service<Input>>. - Async
Service Chain Builder - Returned by
ServiceChain::start_asyncto build an async service chain. Use thenext(self, AsyncService)function to append more services to theServiceChain. Use theend(self)function to finish building and return the resultingServiceChain. - Clone
Service - Clone a
Borrow<T>input, producing the clonedTvalue as output - Cloning
Fork Service - A
Service,MutService, orAsyncServicethat encapsulates two service and accepts aCloneable input, which is passed to both underlying services, returning their outputs as a tuple. - DynAsync
Service - An
AsyncServicewhich encapsulates aBox<dyn AsyncService<...>>. - DynMut
Service - A
MutServicewhich encapsulates aBox<dyn MutService<...>>. - DynService
- A
Servicewhich encapsulates aBox<dyn Service<...>>. - FnMut
Service - A
Service, which encapsulates aFnMut. - FnService
- A
Service, which encapsulates aFn. - Into
Iter Service - Iterate over
Vec<T>input, passing eachTto an underlyingService, returningVec<Output>. - Into
Service - A
Servicewhich can accept any input that can beIntoed an ouput, always returningOk(output). - Maybe
Process Service - A
Servicethat processes aOption<T>as input, processing with an underlyingService<Input = T>when the input isSome, producingOption<S::Output>as output. - MutService
Chain Builder - Returned by
ServiceChain::start_mutto build a mut service chain. Use thenext(self, MutService)function to append more services to theServiceChain. Use theend(self)function to finish building and return the resultingServiceChain. - Mutex
Service - A
Service, which encapsulates aMutService, usingstd::sync::Mutexto aquire mutability in each call toprocess. - NoOp
Service - A
Servicewhich no-ops, passing the input asOk(output). - Poll
Service - A
Service,MutService, orAsyncService, which encapsulates aService<(), Output = Option<T>>,MutService<(), Output = Option<T>>, orAsyncService<(), Output = Option<T>>, blocking with the given idle function until a value is returned or the idle function returns an error. - RefCell
Service - A
Service, which encapsulates aMutService, usingstd::cell::RefCellto aquire mutability in each call toprocess. - RefFork
Service - A
Service,MutService, orAsyncServicethat encapsulates two service and accepts a input as a reference, which is passed to both underlying services, returning their outputs as a tuple. - Retry
Service - A
Service,MutService, orAsyncService, which encapsulates aRetryable, blocking and retrying until a value is returned, an un-retryable error is encountered, or the idle function returns anErr. - Retry
ToOption Service - A
Service, which encapsulates aRetryable, producingNonewhen a retryable event is encounterd. - Service
Async - An
AsyncServicethat encapsulates an underlyingService, exposing it asasync. - Service
Chain - A chain of
Service,MutService, orAsyncServiceimplementations, which is itself a singleService,MutService, orAsyncServicethat 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 anErr, the chain will break early, encapsulate the error in aServiceChainError, and returnErr(ServiceChainError)immediately. - Service
Chain Builder - Returned by
ServiceChain::startto build a sync service chain. Use thenext(self, Service)function to append more services to theServiceChain. Use theend(self)function to finish building and return the resultingServiceChain. - Service
Chain Error - Returned by
ServiceChainwhen a service in the chain returns anErrResult. - Service
Mut - A
MutServicethat encapsulates an underlyingService, exposing it asmut. - Spawn
Service - A
Servicethat accepts aFnOnce()as input, which is passed tospawn(), and produces aJoinHandleas output. - Stop
Service - A
Servicethat will returnOk(Input)when the provided function returns true, or orErr(Stopped)when the provided function returns false. - Stopped
- A generic error that indicates stoppage
- TryInto
Service - A
Servicewhich can accept any input that can beIntoed an ouput, returningResult<Self::Output, TryInto::Error>.
Enums§
- Retry
Error - Used by idle and retry services to interrupt a poll or retry loop
Traits§
- Async
Service - 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
Errto be retried. - Service
- A sync service trait
Attribute Macros§
- async_
trait - Provide support for
async fnby exposing the externalasync_traitcrate. Seeasync_traitfor details.