Page MenuHomeDevCentral

Make PostgreSQL integration optional
ClosedPublic

Authored by dereckson on Oct 9 2018, 00:12.
Tags
None
Referenced Files
F3715350: D1863.diff
Tue, Nov 5, 05:12
Unknown Object (File)
Thu, Oct 31, 11:51
Unknown Object (File)
Mon, Oct 28, 19:51
Unknown Object (File)
Sun, Oct 20, 00:23
Unknown Object (File)
Thu, Oct 17, 00:38
Unknown Object (File)
Tue, Oct 15, 17:25
Unknown Object (File)
Tue, Oct 15, 17:06
Unknown Object (File)
Mon, Oct 14, 13:35
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 Passed
Unit
No Test Coverage
Branch
arcpatch-D1863
Build Status
Buildable 2876
Build 3124: arc lint + arc unit

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.