Small but production-ready webservice in Rust, using Actix web framework.
The service implements an API specification of one feature for goout.net platform. It was shadow-developed alongside main implementation in Kotlin http4k made by @goodhoko at GoOut for comparison and joy.
Multiple implementations of this service exist in different frameworks, languages for comparison.
- locations-kt-http4k in Kotlin http4k; complete,
- locations-kt-ktor in Kotlin Ktor; less complete,
To play/develop:
- Install Rust locally, preferrably using rustup.
- Use Cargo to do all development work:
- Build:
cargo build
- The executable binary is built at
target/debug/locations-rs
- Pass
--release
to compile with optimizations (intotarget/release/
)
- The executable binary is built at
- Build & Run:
cargo run
- Run tests (when there are any):
cargo test
- Check the code compiles (faster than build):
cargo check
- Run additional code analysis, superset of check:
cargo clippy
- Some issues can be automatically fixed with:
cargo fix
- Run additional code analysis, superset of check:
- Check code formatting:
cargo fmt -- --check
- Automatically fix code formatting:
cargo fmt
- Automatically fix code formatting:
- Build documentation:
cargo doc --no-deps
- Point your browser to
target/doc/locations-rs/index.html
- Point your browser to
- Do most of the above at once whenever any file changes using cargo watch:
cargo watch -x clippy -x test -x 'fmt -- --check' -x 'doc --no-deps' -x run
The locations service needs an Elasticsearch instance to operate. The instance should contain
indices city
and region
filled with some data. The GOOUT_ELASTIC_HOST
and GOOUT_ELASTIC_PORT
(usually 9200
) environment variables need to point to the instance.
This repository contains elasticsearch
directory with ready-made dockerized
Elasticsearch instance pre-filled with data. Simply set GOOUT_ELASTIC_HOST
to a host that runs the
Docker image. Note that if both locations and Elasticsearch run in separate Docker containers, one
needs to point locations to host address like 172.17.0.1
(GOOUT_ELASTIC_HOST
of 127.0.0.1
or
0.0.0.0
won't work).
The directory also contains mapping definitions of the 2 indices and example data.
This project is licensed under GNU Affero General Public License, version 3.