App Frame
App Frame is a compile-time dependency-injected application framework with a service orchestrator.
At compile-time, the framework guarantees that all necessary dependencies will be injected upon application startup. You can define dependency relationships using the provided macros or with custom implementations. At runtime, the framework triggers initialization code, then runs services, monitors their health, and reports that health to any external http health checks.
This trivial example illustrates the bare minimum boilerplate to use the framework, but doesn't actually run anything useful.
use ;
async
;
application!;
This example defines and injects various types of components to illustrate the various features provided by the framework:
use Arc;
use async_trait;
use ;
async
// Including a type here implements Provides<ThatType> for MyApp.
//
// Struct definitions wrapped in the `inject!` macro get a From<T>
// implementation where T: Provides<U> for each field of type U in the struct.
// When those structs are provided as a component here, they will be constructed
// with the assumption that MyApp impl Provides<U> for each of those U's
//
// All the types provided here are instantiated separately each time they are
// needed. If you want to support a singleton pattern, you need to construct the
// singletons in the constructor for this type and wrap them in an Arc. Then you
// can provide them in the "provided" section by cloning the Arc.
application!
inject!;
inject!;
inject!;
inject!;
/// This is how you provide a custom alternative to the `inject!` macro, it is
/// practical here since only one item needs to be injected, and the others can
/// be set to default values.
inject!;