Skip to main content

CloudApp

Struct CloudApp 

Source
pub struct CloudApp { /* private fields */ }
Expand description

Cloud application builder — one-line bootstrap for all cloud capabilities.

CloudApp::start() internally executes:

  1. Connect to Nacos (gRPC)
  2. Register service instance
  3. Assemble Axum Router (business routes + actuator routes)
  4. Bind port, start HTTP server
  5. Listen for SIGINT/SIGTERM → graceful shutdown → deregister

Implementations§

Source§

impl CloudApp

Source

pub fn new() -> Self

Create a new CloudApp builder with sensible defaults.

Source

pub fn nacos(self, addr: impl Into<String>) -> Self

Set the Nacos server address (e.g. “127.0.0.1:8848”).

Source

pub fn consul(self, addr: impl Into<String>) -> Self

Set the Consul server address (e.g. “127.0.0.1:8500”).

Source

pub fn namespace(self, ns: impl Into<String>) -> Self

Set the Nacos namespace.

Source

pub fn service_name(self, name: impl Into<String>) -> Self

Set the service name for registration.

Source

pub fn ip(self, ip: impl Into<String>) -> Self

Set the bind IP address (default: “0.0.0.0”).

Source

pub fn port(self, port: u16) -> Self

Set the HTTP port (default: 8080).

Source

pub fn routes(self, routes: Router) -> Self

Set the business routes.

Source

pub fn health_indicator(self, indicator: Arc<dyn HealthIndicator>) -> Self

Add a health indicator.

Source

pub fn metrics_collector(self, collector: Arc<dyn MetricsCollector>) -> Self

Add a metrics collector.

Source

pub fn version(self, version: impl Into<String>) -> Self

Set the service version.

Source

pub fn auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self

Set the Nacos authentication credentials.

Source

pub fn group(self, group: impl Into<String>) -> Self

Set the Nacos group.

Source

pub fn service_info(self, info: ServiceInfo) -> Self

Set the service info (build metadata).

Source

pub async fn start(self) -> Result<(), CloudError>

Start the cloud application.

This method:

  1. Connects to Nacos via gRPC
  2. Registers the service instance
  3. Merges business routes with actuator routes
  4. Starts the HTTP server
  5. Waits for shutdown signal, then gracefully shuts down

This method blocks until the application shuts down.

Trait Implementations§

Source§

impl Default for CloudApp

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more