Page MenuHomeDevCentral

Make PostgreSQL integration optional
ClosedPublic

Authored by dereckson on Oct 9 2018, 00:12.
Tags
None
Referenced Files
F3765897: D1863.id4708.diff
Fri, Nov 22, 15:04
F3765895: D1863.id4706.diff
Fri, Nov 22, 15:03
F3765881: D1863.id4710.diff
Fri, Nov 22, 14:57
F3765866: D1863.id4707.diff
Fri, Nov 22, 14:50
F3765847: D1863.id4705.diff
Fri, Nov 22, 14:44
F3764928: D1863.diff
Fri, Nov 22, 09:19
Unknown Object (File)
Tue, Nov 19, 15:05
Unknown Object (File)
Tue, Nov 19, 10:54
Subscribers
None

Details

Summary

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![
        status,
        favicon,
        getRegistyStats,
        getRepositoryInfo
    ];

    MinimalApplication::start_application(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

Repository
rLF Limiting Factor
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dereckson created this revision.

Could be simplified a lot if we lazy evaluate configuration:

struct BareboneApplication {
}

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

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

Add some missing feature gates

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

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