Elektrobit / flake-pilot

Registration/Control utility for applications launched through a runtime-engine, e.g containers
MIT License
9 stars 5 forks source link

Switch to an object based approach for Pilots #138

Open Ichmed opened 1 year ago

Ichmed commented 1 year ago

Right now each pilot runs by reading a config file, creating an environment and then executing that environment.

This is basically already a constructor and method call approach just abstracted away needlessly. By creating a struct

struct PodmanPilot<'a> {
  config: Config<'a>,
  program_name: String,
  ...
}

impl<'a> Pilot for PodmanPilot<'a> {
  ...
}

And implementing the current create and start functions on that struct we gain the following benefits:

The following things would be possible even though i don't see any need for them:

The new main method would look something like this:

  ...
  let config = config_for_name(&program_name);
  PodmanPilot::from_config(config)?.create()?.run()
}

By implementing Drop on the Pilot struct, cleanup code can also be made easier.