pub struct CloudApp { /* private fields */ }Expand description
Cloud application builder — one-line bootstrap for all cloud capabilities.
CloudApp::start() internally executes:
- Connect to Nacos (gRPC)
- Register service instance
- Assemble Axum Router (business routes + actuator routes)
- Bind port, start HTTP server
- Listen for SIGINT/SIGTERM → graceful shutdown → deregister
Implementations§
Source§impl CloudApp
impl CloudApp
Sourcepub fn nacos(self, addr: impl Into<String>) -> Self
pub fn nacos(self, addr: impl Into<String>) -> Self
Set the Nacos server address (e.g. “127.0.0.1:8848”).
Sourcepub fn consul(self, addr: impl Into<String>) -> Self
pub fn consul(self, addr: impl Into<String>) -> Self
Set the Consul server address (e.g. “127.0.0.1:8500”).
Sourcepub fn service_name(self, name: impl Into<String>) -> Self
pub fn service_name(self, name: impl Into<String>) -> Self
Set the service name for registration.
Sourcepub fn health_indicator(self, indicator: Arc<dyn HealthIndicator>) -> Self
pub fn health_indicator(self, indicator: Arc<dyn HealthIndicator>) -> Self
Add a health indicator.
Sourcepub fn metrics_collector(self, collector: Arc<dyn MetricsCollector>) -> Self
pub fn metrics_collector(self, collector: Arc<dyn MetricsCollector>) -> Self
Add a metrics collector.
Sourcepub fn auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Set the Nacos authentication credentials.
Sourcepub fn service_info(self, info: ServiceInfo) -> Self
pub fn service_info(self, info: ServiceInfo) -> Self
Set the service info (build metadata).
Sourcepub async fn start(self) -> Result<(), CloudError>
pub async fn start(self) -> Result<(), CloudError>
Start the cloud application.
This method:
- Connects to Nacos via gRPC
- Registers the service instance
- Merges business routes with actuator routes
- Starts the HTTP server
- Waits for shutdown signal, then gracefully shuts down
This method blocks until the application shuts down.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CloudApp
impl !UnwindSafe for CloudApp
impl Freeze for CloudApp
impl Send for CloudApp
impl Sync for CloudApp
impl Unpin for CloudApp
impl UnsafeUnpin for CloudApp
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request