-
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.
* simple plugin to log every sec * prepare 1.0.0
- Loading branch information
1 parent
996c6f1
commit d117c67
Showing
4 changed files
with
72 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pub mod device; | ||
use device::Device; | ||
use panduza_platform_core::{DriverOperations, Producer}; | ||
|
||
#[derive(Default)] | ||
pub struct Package {} | ||
|
||
impl Package { | ||
pub fn boxed(self) -> Box<Self> { | ||
Box::new(self) | ||
} | ||
} | ||
|
||
impl Producer for Package { | ||
fn manufacturer(&self) -> String { | ||
"vi".to_string() | ||
} | ||
|
||
fn model(&self) -> String { | ||
"platform_logger".to_string() | ||
} | ||
|
||
fn description(&self) -> String { | ||
"Virtual logger interface".to_string() | ||
} | ||
|
||
fn props(&self) -> panduza_platform_core::Props { | ||
panduza_platform_core::Props::default() | ||
} | ||
|
||
fn produce(&self) -> Result<Box<dyn DriverOperations>, panduza_platform_core::Error> { | ||
return Ok(Box::new(Device::default())); | ||
} | ||
} |
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,34 @@ | ||
use async_trait::async_trait; | ||
use panduza_platform_core::{log_info, spawn_loop, Container, DriverOperations, Error, Instance}; | ||
use std::time::Duration; | ||
use tokio::time::sleep; | ||
|
||
#[derive(Default)] | ||
/// | ||
/// | ||
pub struct Device {} | ||
|
||
#[async_trait] | ||
impl DriverOperations for Device { | ||
/// | ||
/// | ||
/// | ||
async fn mount(&mut self, instance: Instance) -> Result<(), Error> { | ||
let mut instance_2 = instance.clone(); | ||
spawn_loop!("test", instance_2, { | ||
let mut counter: u64 = 0; | ||
loop { | ||
log_info!(instance.logger(), "Hello {}", counter); | ||
tokio::time::sleep(Duration::from_secs(1)).await; | ||
counter += 1; | ||
} | ||
}); | ||
Ok(()) | ||
} | ||
/// | ||
/// Easiest way to implement the reboot event | ||
/// | ||
async fn wait_reboot_event(&mut self, mut _device: Instance) { | ||
sleep(Duration::from_secs(5)).await; | ||
} | ||
} |