Skip to content

aetheric-oss/svc-scheduler

Repository files navigation

Aetheric Banner

svc-scheduler Service

GitHub stable release (latest by date) GitHub release (latest by date including pre-releases) Coverage Status Sanity Checks Python PEP8 Rust Checks Arrow DAO Discord

🔭 Overview

svc-scheduler is responsible for scheduling, confirming and canceling flights. The service exposes two crates:

  • server - [bin] target to run gRPC server
  • client - [lib] target for other services to import and use

Directory:

  • server/src: Source Code and Unit Tests for scheduler-service server
  • client-grpc/src: Source Code for scheduler-service client
  • proto/: Types used for gRPC messaging
  • client/tests/: Integration Tests
  • docs/: Module Documentation

Installation

Install Rust with Rustup.

# Adds custom pre-commit hooks to .git through cargo-husky dependency
# !! Required for developers !!
cargo test

Make

Build and Test

To ensure consistent build and test outputs, Arrow provides a Docker image with all required software installed to build and test Rust projects. Using the Makefile, you can easily test and build your code.

# Build Locally
make rust-build

# Create Deployment Container
make build

# Run Deployment Container
make docker-run

# Stopping Deployment Container
make docker-stop

# Running examples (uses docker compose file)
make rust-example-grpc

Formatting

The Arrow docker image has some formatting tools installed which can fix your code formatting for you. Using the Makefile, you can easily run the formatters on your code. Make sure to commit your code before running these commands, as they might not always result in the desired outcome.

# Format TOML files
make toml-tidy

# Format Rust files
make rust-tidy

# Format Python files
make python-tidy

# Format all at once
make tidy

Spell check

Before being able to commit, cspell will be used as a spelling checker for all files, making sure no unintended spelling errors are found. You can run cspell yourself by using the following make target:

make cspell-test

If all spelling errors are fixed, but cspell still finds words that are unknown, you can add these words to the local project words list by running the following command:

make cspell-add-words

Other make Targets

There are additional make targets available. You can find all possible targets by running make without a target or use make help

Debugging

All unit tests start with initialization of the logger, allowing for easier debugging when tests are failing. Since the log files are written as json, it's easy to search for log messages using jq. You can adjust the log level in the log4rs.yaml config file if needed.

Example jq query, to get all messages generated by the router when running test_query_flight_9_deadhead_destination_flight_no_capacity_at_destination_vertiport:

cat server/logs/router.log | jq -c '. | select(.thread=="grpc::queries::tests::test_query_flight_9_deadhead_destination_flight_no_capacity_at_destination_vertiport") | .message'

Additionally, you could grep on the function name you want to track the log output for:

cat server/logs/router.log | jq -c '. | select(.thread=="grpc::queries::tests::test_query_flight_9_deadhead_destination_flight_no_capacity_at_destination_vertiport") | .message' | grep 'get_possible_flights'

Get all logs for a specific test

It is also possible to find all log messages generated by a specific test. For this, you first need to find the thread_id:

cat server/logs/tests.log | jq -c '. | { message: .message, thread_id: .thread_id, date: .time}' | grep 'test_query_flight_9'

You can then use this thread_id (without quotes!) to find all messages in all log files generated by this thread:

cat server/logs/*.log | jq -c '[.] | sort_by(.time) | .[] | select(.thread_id==<insert_your_thread_id>) | .message'

📜 Documentation

The following documents are relevant to this service:

👥 Arrow DAO

Learn more about us:

LICENSE Notice

Please note that svc-scheduler is under BUSL license until the Change Date, currently the earlier of two years from the release date. Exceptions to the license may be specified by Arrow Governance via Additional Use Grants, which can, for example, allow svc-scheduler to be deployed for certain production uses. Please reach out to Arrow DAO to request a DAO vote for exceptions to the license, or to move up the Change Date.

❗ Treatment of Cargo.lock

If you are building a non-end product like a library, include Cargo.lock in .gitignore.

If you are building an end product like a command line tool, check Cargo.lock to the git.

Read more about it here.