Compare commits
No commits in common. "main" and "v0.4.0" have entirely different histories.
@ -41,11 +41,3 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
Can be found (here)[crates/mad/examples]
|
|
||||||
|
|
||||||
- basic
|
|
||||||
- fn
|
|
||||||
- signals
|
|
||||||
- error_log
|
|
||||||
|
@ -10,7 +10,7 @@ impl mad::Component for WaitServer {
|
|||||||
Some("WaitServer".into())
|
Some("WaitServer".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run(&self, _cancellation: CancellationToken) -> Result<(), mad::MadError> {
|
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> {
|
||||||
let millis_wait = rand::thread_rng().gen_range(500..3000);
|
let millis_wait = rand::thread_rng().gen_range(500..3000);
|
||||||
|
|
||||||
tracing::debug!("waiting: {}ms", millis_wait);
|
tracing::debug!("waiting: {}ms", millis_wait);
|
||||||
@ -28,11 +28,9 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.with_max_level(Level::TRACE)
|
.with_max_level(Level::TRACE)
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let item = "some item".to_string();
|
|
||||||
|
|
||||||
mad::Mad::builder()
|
mad::Mad::builder()
|
||||||
.add(WaitServer {})
|
.add(WaitServer {})
|
||||||
.add_fn(|_cancel| async move {
|
.add_fn(|cancel| async move {
|
||||||
let millis_wait = 50;
|
let millis_wait = 50;
|
||||||
|
|
||||||
tracing::debug!("waiting: {}ms", millis_wait);
|
tracing::debug!("waiting: {}ms", millis_wait);
|
||||||
@ -42,24 +40,6 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.add_fn(move |_cancel| {
|
|
||||||
// I am an actual closure
|
|
||||||
|
|
||||||
let item = item.clone();
|
|
||||||
|
|
||||||
async move {
|
|
||||||
let _item = item;
|
|
||||||
|
|
||||||
let millis_wait = 50;
|
|
||||||
|
|
||||||
tracing::debug!("waiting: {}ms", millis_wait);
|
|
||||||
|
|
||||||
// Simulates a server running for some time. Is normally supposed to be futures blocking indefinitely
|
|
||||||
tokio::time::sleep(std::time::Duration::from_millis(millis_wait)).await;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.run()
|
.run()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user