pub struct Assembly<T> {
pub top: T,
/* private fields */
}Expand description
Main entry point for a Comprehensive server.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
comprehensive::Assembly::<TopDependencies>::new()?.run().await
}Fields§
§top: TThe constructed instances of the top-level (root) dependencies. Access to this is freqently not required as these resources will work autonomously once included in the graph.
Implementations§
Source§impl<T> Assembly<T>where
T: ResourceDependencies,
impl<T> Assembly<T>where
T: ResourceDependencies,
Sourcepub fn new() -> Result<Self, Box<dyn Error>>
pub fn new() -> Result<Self, Box<dyn Error>>
Build a new Assembly from the given resources and all their
transitive dependencies.
Sourcepub fn new_from_argv<I, A>(argv: I) -> Result<Self, Box<dyn Error>>
pub fn new_from_argv<I, A>(argv: I) -> Result<Self, Box<dyn Error>>
Build a new Assembly from the given resources and all their
transitive dependencies, with a given command line argv.
Mostly for testing.
Sourcepub async fn run(self) -> Result<(), Box<dyn Error>>
pub async fn run(self) -> Result<(), Box<dyn Error>>
Run an Assembly by invoking and awaiting every resource in the graph.
Runs until either any Resource terminates with an error, a termination signal is received (and graceful shutdown is finished), or all resources terminate successfully. (Returns immediately on an empty graph.)
Sourcepub async fn run_with_termination_signal(
self,
termination_signal: impl Stream<Item = ()> + Unpin,
) -> Result<(), Box<dyn Error>>
pub async fn run_with_termination_signal( self, termination_signal: impl Stream<Item = ()> + Unpin, ) -> Result<(), Box<dyn Error>>
Run an Assembly by invoking and awaiting every resource in the graph.
Callers should usually use Assembly::run instead, which installs a
SIGTERM handler and then calls this with it.
Sourcepub fn write_graph(w: &mut dyn Write)
pub fn write_graph(w: &mut dyn Write)
Write the constructed graph in Graphviz dot format.
Can be invoked by running an Assembly with the special flag
--write_graph_and_exit on the command line.
Auto Trait Implementations§
impl<T> !Freeze for Assembly<T>
impl<T> !RefUnwindSafe for Assembly<T>
impl<T> Send for Assembly<T>where
T: Send,
impl<T> !Sync for Assembly<T>
impl<T> Unpin for Assembly<T>where
T: Unpin,
impl<T> !UnwindSafe for Assembly<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Erasable for T
impl<T> Erasable for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more