Skip to content
← All projects

Rust · Rocket · Diesel · PostgreSQL · r2d2

Rusti aircraft API

A Rust aircraft CRUD API built with Rocket, Diesel, PostgreSQL, and an r2d2 request guard that returns 503 when the pool is exhausted.

Role
Sole author
Year
Claims
code-verified
Repository
Source

Context and scope

A learning project built with Rocket, Diesel, and PostgreSQL. Its primary design concern is database connection management through Rocket's request-guard system.

System design

Persistence model

The service uses pre-async Rocket with Diesel over PostgreSQL. airplanes.rs defines a Diesel model that derives Queryable, Insertable, AsChangeset, and serde traits.

The Diesel query builder implements list, create, read by ID, update, and delete operations for a single aircraft resource.

Connection acquisition

pg_pool.rs wraps an r2d2 connection pool and exposes pooled connections through FromRequest.

Handlers declare the connection in their signatures. Rocket acquires the connection before invoking the handler and returns it to the pool when the request completes.

A Deref implementation exposes the underlying connection at Diesel call sites without repeated wrapper access.

Pool-exhaustion behavior

When the pool cannot provide a connection, the request guard returns ServiceUnavailable.

This converts resource exhaustion into an explicit 503 response rather than allowing connection acquisition to create unbounded request latency.

Design decisions

DecisionRationale
Expose pooled connections through a request guardMakes database access explicit in the handler signature and delegates acquisition and release to the framework.
Return ServiceUnavailable when the pool is exhaustedBounds the failure with an explicit response instead of allowing requests to wait indefinitely.
Implement Deref for the connection wrapperKeeps Diesel call sites direct without exposing wrapper internals repeatedly.

Verification status

The repository contains CRUD behavior and a small test module. The implementation has not been validated under production load.

Known limitations

Authentication

Authentication is not operational and is not presented as complete. auth.rs contains bcrypt registration and login code with tests, but the module is commented out.

Runtime and operational scope

The project predates async Rocket. It implements one CRUD resource, has limited automated coverage, and has no production deployment or load-test evidence.

Contact

Available now. Permanent senior or staff platform roles, in Munich or remote within the EU.

Email is the fastest way to reach me.