Skip to content

Builder pattern for creating control groups #5

@levex

Description

@levex

I've started working on an API that looks like this:

let cgroup: Cgroup = CgroupBuilder::new("hello", V1)
    .memory()
        .kernel_memory_limit(1024 * 1024)
        .memory_hard_limit(1024 * 1024)
        .done()
    .cpu()
        .shares(100)
        .done()
    .build();

Thoughts?

In particular, I'd prefer to leave out an API that adds a pid to the control group. That's racy and it might introduce subtle race conditions into applications depending on this crate. Instead, the API will likely include an include_command() build that starts the Command in the control group. This would be done via a trait ideally, so people can extend it.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions