Compare commits
1 Commits
v0.2.1
...
1ce63ff7bf
Author | SHA1 | Date | |
---|---|---|---|
|
1ce63ff7bf |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -6,16 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.2.1] - 2024-08-07
|
|
||||||
|
|
||||||
### Docs
|
|
||||||
- add a small readme
|
|
||||||
|
|
||||||
## [0.2.0] - 2024-08-07
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- with ctrl-c signal
|
|
||||||
|
|
||||||
## [0.1.0] - 2024-08-07
|
## [0.1.0] - 2024-08-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.1"
|
version = "0.1.0"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
mad = { path = "crates/mad" }
|
mad = { path = "crates/mad" }
|
||||||
|
43
README.md
43
README.md
@@ -1,43 +0,0 @@
|
|||||||
# MAD
|
|
||||||
|
|
||||||
Mad is a life-cycle manager for long running rust operations.
|
|
||||||
|
|
||||||
- Webservers
|
|
||||||
- Queue bindings
|
|
||||||
- gRPC servers etc
|
|
||||||
- Cron runners
|
|
||||||
|
|
||||||
It is supposed to be the main thing the application runs, and everything from it is spawned and managed by it.
|
|
||||||
|
|
||||||
```rust
|
|
||||||
struct WaitServer {}
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl Component for WaitServer {
|
|
||||||
fn name(&self) -> Option<String> {
|
|
||||||
Some("NeverEndingRun".into())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> {
|
|
||||||
let millis_wait = rand::thread_rng().gen_range(50..1000);
|
|
||||||
|
|
||||||
// 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(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
|
||||||
async fn main() -> anyhow::Result<()> {
|
|
||||||
Mad::builder()
|
|
||||||
.add(WaitServer {})
|
|
||||||
.add(WaitServer {})
|
|
||||||
.add(WaitServer {})
|
|
||||||
.run()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
@@ -134,10 +134,6 @@ impl Mad {
|
|||||||
}
|
}
|
||||||
res = comp.run(job_cancellation) => {
|
res = comp.run(job_cancellation) => {
|
||||||
error_tx.send(res).await
|
error_tx.send(res).await
|
||||||
|
|
||||||
}
|
|
||||||
_ = tokio::signal::ctrl_c() => {
|
|
||||||
error_tx.send(Ok(())).await
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user