busybeaver 0.1.4

This Beaver executes your Futures independently of your worker threads, supporting scheduling strategies such as time intervals, execution count intervals, specific-time polling policies, and more.
Documentation

BusyBeaver


中文

BusyBeaver 是一个带可配置重试策略的异步任务执行器,适用于 Rust 异步运行时(如 Tokio)。

特性

  • 可配置的重试策略与退避
  • 支持按次数、按周期、按时间间隔等任务类型
  • 任务监听与进度回调
  • 与 Tokio 集成

集成文档

快速开始

[dependencies]
busybeaver = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "macros"] }
use busybeaver::{work, Beaver, PeriodicBuilder, WorkResult};
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let beaver = Beaver::new("default", 256);
    let task = PeriodicBuilder::new(work(|| async { WorkResult::Done(()) }))
        .interval(Duration::from_millis(100))
        .build()?;
    beaver.enqueue(task).await?;
    tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
    beaver.cancel_all().await?;
    beaver.destroy().await?;
    Ok(())
}

许可证

MIT OR Apache-2.0


English

BusyBeaver is a resilient async task executor with configurable retry policies for Rust async runtimes (e.g. Tokio).

Features

  • Configurable retry policies and backoff
  • Task types: fixed count, periodic, time interval
  • Task listeners and progress callbacks
  • Tokio integration

Integration docs

Quick start

[dependencies]
busybeaver = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "macros"] }
use busybeaver::{work, Beaver, PeriodicBuilder, WorkResult};
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let beaver = Beaver::new("default", 256);
    let task = PeriodicBuilder::new(work(|| async { WorkResult::Done(()) }))
        .interval(Duration::from_millis(100))
        .build()?;
    beaver.enqueue(task).await?;
    tokio::time::sleep(tokio::time::Duration::from_millis(200)).await;
    beaver.cancel_all().await?;
    beaver.destroy().await?;
    Ok(())
}

License

MIT OR Apache-2.0