feat: update name
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-11-19 17:20:41 +01:00
parent d51716893f
commit 5c88cdd3e3
Signed by: kjuulh
GPG Key ID: D85D7535F18F35FA
5 changed files with 19 additions and 19 deletions

View File

@ -5,12 +5,12 @@ use tracing::Level;
struct WaitServer {} struct WaitServer {}
#[async_trait] #[async_trait]
impl mad::Component for WaitServer { impl notmad::Component for WaitServer {
fn name(&self) -> Option<String> { fn name(&self) -> Option<String> {
Some("WaitServer".into()) Some("WaitServer".into())
} }
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> { async fn run(&self, cancellation: CancellationToken) -> Result<(), notmad::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,7 +28,7 @@ async fn main() -> anyhow::Result<()> {
.with_max_level(Level::TRACE) .with_max_level(Level::TRACE)
.init(); .init();
mad::Mad::builder() notmad::Mad::builder()
.add(WaitServer {}) .add(WaitServer {})
.add(WaitServer {}) .add(WaitServer {})
.add(WaitServer {}) .add(WaitServer {})

View File

@ -5,12 +5,12 @@ use tracing::Level;
struct ErrorServer {} struct ErrorServer {}
#[async_trait] #[async_trait]
impl mad::Component for ErrorServer { impl notmad::Component for ErrorServer {
fn name(&self) -> Option<String> { fn name(&self) -> Option<String> {
Some("ErrorServer".into()) Some("ErrorServer".into())
} }
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> { async fn run(&self, cancellation: CancellationToken) -> Result<(), notmad::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);
@ -18,7 +18,7 @@ impl mad::Component for ErrorServer {
// Simulates a server running for some time. Is normally supposed to be futures blocking indefinitely // 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; tokio::time::sleep(std::time::Duration::from_millis(millis_wait)).await;
Err(mad::MadError::Inner(anyhow::anyhow!("expected error"))) Err(notmad::MadError::Inner(anyhow::anyhow!("expected error")))
} }
} }
@ -30,7 +30,7 @@ async fn main() -> anyhow::Result<()> {
// Do note that only the first server which returns an error is guaranteed to be handled. This is because if servers don't respect cancellation, they will be dropped // Do note that only the first server which returns an error is guaranteed to be handled. This is because if servers don't respect cancellation, they will be dropped
mad::Mad::builder() notmad::Mad::builder()
.add(ErrorServer {}) .add(ErrorServer {})
.add(ErrorServer {}) .add(ErrorServer {})
.add(ErrorServer {}) .add(ErrorServer {})

View File

@ -5,12 +5,12 @@ use tracing::Level;
struct WaitServer {} struct WaitServer {}
#[async_trait] #[async_trait]
impl mad::Component for WaitServer { impl notmad::Component for WaitServer {
fn name(&self) -> Option<String> { fn name(&self) -> Option<String> {
Some("WaitServer".into()) Some("WaitServer".into())
} }
async fn run(&self, _cancellation: CancellationToken) -> Result<(), mad::MadError> { async fn run(&self, _cancellation: CancellationToken) -> Result<(), notmad::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);
@ -30,7 +30,7 @@ async fn main() -> anyhow::Result<()> {
let item = "some item".to_string(); let item = "some item".to_string();
mad::Mad::builder() notmad::Mad::builder()
.add(WaitServer {}) .add(WaitServer {})
.add_fn(|_cancel| async move { .add_fn(|_cancel| async move {
let millis_wait = 50; let millis_wait = 50;

View File

@ -5,12 +5,12 @@ use tracing::Level;
struct WaitServer {} struct WaitServer {}
#[async_trait] #[async_trait]
impl mad::Component for WaitServer { impl notmad::Component for WaitServer {
fn name(&self) -> Option<String> { fn name(&self) -> Option<String> {
Some("WaitServer".into()) Some("WaitServer".into())
} }
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> { async fn run(&self, cancellation: CancellationToken) -> Result<(), notmad::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);
@ -24,12 +24,12 @@ impl mad::Component for WaitServer {
struct RespectCancel {} struct RespectCancel {}
#[async_trait] #[async_trait]
impl mad::Component for RespectCancel { impl notmad::Component for RespectCancel {
fn name(&self) -> Option<String> { fn name(&self) -> Option<String> {
Some("RespectCancel".into()) Some("RespectCancel".into())
} }
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> { async fn run(&self, cancellation: CancellationToken) -> Result<(), notmad::MadError> {
cancellation.cancelled().await; cancellation.cancelled().await;
tracing::debug!("stopping because job is cancelled"); tracing::debug!("stopping because job is cancelled");
@ -39,12 +39,12 @@ impl mad::Component for RespectCancel {
struct NeverStopServer {} struct NeverStopServer {}
#[async_trait] #[async_trait]
impl mad::Component for NeverStopServer { impl notmad::Component for NeverStopServer {
fn name(&self) -> Option<String> { fn name(&self) -> Option<String> {
Some("NeverStopServer".into()) Some("NeverStopServer".into())
} }
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> { async fn run(&self, cancellation: CancellationToken) -> Result<(), notmad::MadError> {
// Simulates a server running for some time. Is normally supposed to be futures blocking indefinitely // Simulates a server running for some time. Is normally supposed to be futures blocking indefinitely
tokio::time::sleep(std::time::Duration::from_millis(999999999)).await; tokio::time::sleep(std::time::Duration::from_millis(999999999)).await;
@ -58,7 +58,7 @@ async fn main() -> anyhow::Result<()> {
.with_max_level(Level::TRACE) .with_max_level(Level::TRACE)
.init(); .init();
mad::Mad::builder() notmad::Mad::builder()
.add(WaitServer {}) .add(WaitServer {})
.add(NeverStopServer {}) .add(NeverStopServer {})
.add(RespectCancel {}) .add(RespectCancel {})

View File

@ -1,5 +1,5 @@
use async_trait::async_trait; use async_trait::async_trait;
use mad::{Component, Mad}; use notmad::{Component, Mad};
use rand::Rng; use rand::Rng;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
use tracing_test::traced_test; use tracing_test::traced_test;
@ -12,7 +12,7 @@ impl Component for NeverEndingRun {
Some("NeverEndingRun".into()) Some("NeverEndingRun".into())
} }
async fn run(&self, cancellation: CancellationToken) -> Result<(), mad::MadError> { async fn run(&self, cancellation: CancellationToken) -> Result<(), notmad::MadError> {
let millis_wait = rand::thread_rng().gen_range(50..1000); let millis_wait = rand::thread_rng().gen_range(50..1000);
tokio::time::sleep(std::time::Duration::from_millis(millis_wait)).await; tokio::time::sleep(std::time::Duration::from_millis(millis_wait)).await;