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 functions that may optionally be used by
crate::RetryServiceandcrate::PollService.
Structs
- A
Service, which encapsulates anArc<Service<Input>>. - A
Service, which encapsulates anArc<Service<Input>>. - 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 a
Borrow<T>input, producing the clonedTvalue as output - A
Service,MutService, orAsyncServicethat encapsulates two service and accepts aCloneable input, which is passed to both underlying services, returning their outputs as a tuple. - An
AsyncServicewhich encapsulates aBox<dyn AsyncService<...>>. - A
MutServicewhich encapsulates aBox<dyn MutService<...>>. - A
Servicewhich encapsulates aBox<dyn Service<...>>. - A
Servicethat processes aOption<T>as input, processing with an underlying [Service<Input = T>] when the input isSome, producingOption<S::Output>as output. - 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. - A
Service, which encapsulates aMutService, usingstd::sync::Mutexto aquire mutability in each call toprocess. - A
Servicewhich no-ops, passing the input asOk(output). - 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. - A
Service, which encapsulates aMutService, usingstd::cell::RefCellto aquire mutability in each call toprocess. - 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. - 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. - 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. - 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. - A
Servicethat accepts aFnOnce()as input, which is passed tospawn(), and produces aJoinHandleas output. - A
Servicethat will returnOk(Input)when the provided function returns true, or orErr(Stopped)when the provided function returns false. - A generic error that indicates stoppage
Enums
- Used by idle and retry services to interrupt a poll or retry loop
Traits
- An async service trait
- A mut service trait
- To be implemented by non-blocking services which may return the moved input in a resulting
Errto be retried. - A sync service trait
Attribute Macros
- Provide support for
async fnby exposing the externalasync_traitcrate. Seeasync_traitfor details.