Page MenuHomeDevCentral

Make PostgreSQL integration optional
ClosedPublic

Authored by dereckson on Oct 9 2018, 00:12.
Tags
None
Referenced Files
F2748994: D1863.id4705.diff
Fri, Mar 29, 11:41
F2748991: D1863.id4706.diff
Fri, Mar 29, 11:41
F2745985: D1863.id4709.diff
Fri, Mar 29, 01:17
Unknown Object (File)
Thu, Mar 28, 04:46
Unknown Object (File)
Thu, Mar 28, 04:10
Unknown Object (File)
Sun, Mar 24, 19:23
Unknown Object (File)
Sat, Mar 23, 08:13
Unknown Object (File)
Sat, Mar 23, 04:10
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.