Crate shuttle_runtime

Source
Expand description

§Shuttle - Deploy Rust apps with a single command

Shuttle is a Rust-native cloud development platform that lets you deploy your Rust apps for free.

📖 Check out our documentation to get started quickly: docs.shuttle.dev

🙋‍♂️ If you have any questions, join our Discord server.

§Usage

Start by installing the Shuttle CLI by running the following in a terminal:

cargo install cargo-shuttle

Now that Shuttle is installed, you can initialize a project with Axum boilerplate:

shuttle init --template axum my-axum-app

By looking at the Cargo.toml file of the generated my-axum-app project you will see it has been made to be a binary crate with a few dependencies including shuttle-runtime and shuttle-axum.

axum = "0.7.3"
shuttle-axum = "0.52.0"
shuttle-runtime = "0.52.0"
tokio = "1.28.2"

A boilerplate code for your axum project can also be found in src/main.rs:

use axum::{routing::get, Router};

async fn hello_world() -> &'static str {
    "Hello, world!"
}

#[shuttle_runtime::main]
async fn main() -> shuttle_axum::ShuttleAxum {
    let router = Router::new().route("/", get(hello_world));

    Ok(router.into())
}

Check out our docs to see all the frameworks we support, or our examples if you prefer that format.

§Running locally

To test your app locally before deploying, use:

shuttle run

You should see your app build and start on the default port 8000. You can test this using;

curl http://localhost:8000/
# Hello, world!

§Deploying

Deploy the service with:

shuttle deploy

Your service will then be made available under a subdomain of *.shuttle.app. For example:

curl https://my-axum-app-0000.shuttle.app/
# Hello, world!

Re-exports§

pub use tokio;

Structs§

DbInput
The input given to Shuttle DB resources
DeploymentMetadata
Metadata
Shuttle Metadata
ResourceFactory
A factory for getting metadata when building resources
SecretStore
Store that holds all the secrets available to a deployment
Secrets
Shuttle Secrets

Enums§

Environment
The environment this project is running in
Error
An error that can occur in the process of building and deploying a service.

Traits§

IntoResource
Implement this on an ResourceInputBuilder::Output type to turn the base resource into the end type exposed to the Shuttle main function.
ResourceInputBuilder
Allows implementing plugins for the Shuttle main function.
Service
The core trait of the Shuttle platform. Every service deployed to Shuttle needs to implement this trait.

Type Aliases§

CustomError
Type alias for an anyhow::Error.

Attribute Macros§

async_trait
main
Helper macro that generates the entrypoint required by any service - likely the only macro you need in this crate.