- Build, test and deploy
- Run rustfmt, clippy and doc build
Main features. Comes with the kitchen sink. Remove what you don't need.
- Command line argument parsing using
StructOpt
. - Version info including commit hash.
- Error handling using
anyhow
andthiserror
. - Logging using
tracing
withlog
andfutures
compatibility,-v
,-vv
, etc. command line arguments. - Preloaded with
serde
,rand
,rayon
,itertools
. - Tests using
proptest
,pretty_assertions
andfloat_eq
. I recommend the closure style proptests. - Benchmarks using
criterion
(runcargo criterion
). - Dependencies build optimized, also in dev build.
- From scratch Docker build statically linked to musl.
Using GitHub actions for each PR it will push a Docker container image to the Github container registry. A Helm chart is included for easy deployment to Kubernetes clusters. The ingress rule assumes a Traefik frontend.
Todo: Tutorial using: https://github.com/redkubes/otomi-core
Lint, build, test, run
cargo fmt && cargo clippy --all-targets --all-features && cargo build --all-targets --all-features && cargo test && cargo run --
Run benchmarks
cargo bench --bench criterion --features="bench proptest"
Update Cargo.toml
and regenerate deploy/Chart.yaml
from it using the included script:
./deploy/generate.py > ./deploy/Chart.yaml
Change the name of the crate from rust_service_template
to the new name in ./criterion.rs
and ./src/cli/main.rs
.
Implement your service in src/lib.rs
.
If your service makes outbound connections, add egress rules to deploy/templates/network-policy.yaml
.
Deploy using Helm on a Kubernetes cluster using Traefik for ingress management.
Copy from Tokio:
-
Add license, contributing, and other changelogs
-
Rustdocs with Katex.
-
Long running / fuzz mode for proptests.
-
loom
support for concurrency testing, maybesimulation
. -
Add crates.io publishing
for arch in x86_64 aarch64; do
docker run --rm \
-v "$(pwd)":/src \
-v $HOME/.cargo:/usr/local/cargo:Z \
-v /usr/local/cargo/bin \
ghcr.io/recmo/rust-static-build:1.58-$arch \
cargo build --locked --release --features mimalloc
done
for arch in amd64 arm64; do
docker build --platform linux/$arch --tag rust-service-template:latest-$arch .
done
docker manifest rm ghcr.io/recmo/rust-service-template:latest
docker manifest create \
rust-service-template:latest \
rust-service-template:latest-amd64 \
rust-service-template:latest-arm64
docker manifest inspect rust-service-template:latest