Page MenuHomeDevCentral

Make PostgreSQL integration optional
ClosedPublic

Authored by dereckson on Oct 9 2018, 00:12.
Tags
None
Referenced Files
F3928557: D1863.id.diff
Sun, Dec 22, 05:29
F3926191: D1863.id4710.diff
Sat, Dec 21, 20:32
Unknown Object (File)
Tue, Dec 17, 02:52
Unknown Object (File)
Mon, Dec 16, 04:41
Unknown Object (File)
Sun, Dec 15, 13:32
Unknown Object (File)
Thu, Dec 12, 10:19
Unknown Object (File)
Thu, Dec 12, 05:43
Unknown Object (File)
Tue, Dec 10, 08:11
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.