Page MenuHomeDevCentral

Make PostgreSQL integration optional

Authored by dereckson on Oct 9 2018, 00:12.



Some API microservices don't need a database, as they only compute data
or fetches it from other datasources.

As such, Cargo features are prepared to allow to create a build without
diesel/r2d2 integration.

In the same way, even if we compile againt those crates, it's valuable
to make the database an option at runtime too.

Finally, to offer minimal configuration and application is valuable too
to simplify the creation of a minimal microservice. That allows code like:

//! Docker Registry API application entry point

use crate::requests::*;
use limiting_factor::kernel::MinimalApplication;

pub fn run () {
    let routes = routes![


Fixes T1421.

Test Plan

Test the code above with the following Cargo entry:
limiting-factor = { path = "../limiting-factor", features = ["minimal"] }

Compile the crate both in minimal and default features profiles.

Diff Detail

rLF Limiting Factor
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

dereckson requested review of this revision.Oct 9 2018, 00:12
dereckson created this revision.
dereckson planned changes to this revision.Oct 9 2018, 00:46

Could be simplified a lot if we lazy evaluate configuration:

struct BareboneApplication {
dereckson edited the summary of this revision. (Show Details)Oct 9 2018, 10:18
dereckson updated this revision to Diff 4706.Oct 9 2018, 11:28

DefaultApplication → BaseApplication ; DefaultApplication as an helper wrapper to force config type, exactly like MinimalApplication.

dereckson updated this revision to Diff 4707.Oct 9 2018, 12:30

Separate concerns for application (CLI runner, with exit codes) and service (run the Rocket server, returns error)

dereckson updated this revision to Diff 4708.Oct 9 2018, 13:04

Add some missing feature gates

dereckson edited the test plan for this revision. (Show Details)Oct 9 2018, 13:04
dereckson updated this revision to Diff 4709.Oct 9 2018, 13:14

Restore cargo configuration to use the full profile by default, Fix an eager replace for DefaultApplication → BaseApplication in the documentation.

dereckson accepted this revision.Oct 9 2018, 13:46
This revision is now accepted and ready to land.Oct 9 2018, 13:46
This revision was automatically updated to reflect the committed changes.