-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A new dummy TemplateWorker for development and documentation purposes.
- Loading branch information
Showing
4 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::{fmt::Display}; | ||
|
||
use core_affinity::CoreId; | ||
use log::info; | ||
|
||
use crate::{BaseConfig, Worker, WorkerError, WorkloadConfig}; | ||
|
||
struct TemplateWorkload { | ||
restart_interval: u64, | ||
} | ||
|
||
pub struct TemplateWorker { | ||
config: BaseConfig, | ||
workload: TemplateWorkload, | ||
} | ||
|
||
impl TemplateWorker { | ||
pub fn new( | ||
workload: WorkloadConfig, | ||
cpu: CoreId, | ||
process: usize, | ||
) -> Self { | ||
let WorkloadConfig { | ||
restart_interval, | ||
workload: _, | ||
} = workload; | ||
|
||
TemplateWorker { | ||
config: BaseConfig { cpu, process }, | ||
workload: TemplateWorkload { | ||
restart_interval, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
impl Worker for TemplateWorker { | ||
fn run_payload(&self) -> Result<(), WorkerError> { | ||
info!("{self}"); | ||
|
||
let TemplateWorkload { | ||
restart_interval, | ||
} = self.workload; | ||
|
||
// Do something here | ||
info!("{restart_interval}"); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
impl Display for TemplateWorker { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.config) | ||
} | ||
} |