Simpify Config transmission mode

Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
This commit is contained in:
Zhang Tianyang 2022-02-17 11:13:49 +08:00
parent 620ce26d59
commit db4e648261
3 changed files with 5 additions and 6 deletions

View File

@ -19,5 +19,5 @@ mod service;
use crate::service::Service;
fn main() {
containerd_shim::run::<Service>("io.containerd.runc.v2", Vec::new())
containerd_shim::run::<Service>("io.containerd.runc.v2", None)
}

View File

@ -79,5 +79,5 @@ impl shim::Task for Service {
}
fn main() {
shim::run::<Service>("io.containerd.empty.v1", Vec::new())
shim::run::<Service>("io.containerd.empty.v1", None)
}

View File

@ -186,7 +186,7 @@ pub trait Shim {
}
/// Shim entry point that must be invoked from `main`.
pub fn run<T>(runtime_id: &str, opts: Vec<fn(&mut Config)>)
pub fn run<T>(runtime_id: &str, opts:Option<Config>)
where
T: Shim + Send + Sync + 'static,
{
@ -196,7 +196,7 @@ where
}
}
fn bootstrap<T>(runtime_id: &str, opts: Vec<fn(&mut Config)>) -> Result<()>
fn bootstrap<T>(runtime_id: &str, opts: Option<Config>) -> Result<()>
where
T: Shim + Send + Sync + 'static,
{
@ -208,8 +208,7 @@ where
let publisher = publisher::RemotePublisher::new(&ttrpc_address)?;
// Create shim instance
let mut config = Config::default();
opts.iter().for_each(|f| f(&mut config));
let mut config = opts.unwrap_or_else(Config::default);
// Setup signals
let signals = setup_signals(&config);