Skip to main content

Crate pollen_rs

Crate pollen_rs 

Source
Expand description

Pollen: Embedded Decentralized Distributed Task Scheduler

Pollen is like SQLite for task scheduling, but with peer-to-peer cluster capabilities.

§Quick Start

use pollen::{Pollen, Schedule, Storage};
use std::time::Duration;

#[tokio::main]
async fn main() -> pollen::Result<()> {
    // Single-node mode
    let scheduler = Pollen::builder()
        .storage(Storage::sqlite("./pollen.db"))
        .build()
        .await?;

    // Define a task with cron schedule
    scheduler.define("daily_report")
        .schedule(Schedule::cron("0 9 * * *"))
        .handler(|| async { Ok(()) })
        .register()
        .await?;

    Ok(())
}

§Features

  • metrics - Enable Prometheus metrics collection
  • otel - Enable OpenTelemetry integration
  • full - Enable all optional features

Modules§

prelude
Re-export commonly used types

Structs§

ClusterConfig
Cluster configuration for the builder
ClusterState
Cluster state information
ExecutorSettings
Executor configuration
InstanceId
Unique identifier for a task instance (single execution).
NodeId
Unique identifier for a node in the cluster.
NodeInfo
Node information in cluster
Pollen
Main Pollen scheduler instance
PollenBuilder
Builder for constructing a Pollen scheduler instance
RetryPolicy
Retry policy for failed tasks.
TaskBuilder
Task builder for fluent task definition
TaskConfig
Task configuration options.
TaskDef
Task definition - the blueprint for a scheduled task.
TaskId
Unique identifier for a task definition.
TaskInfo
Task information
TaskInstance
Task instance - a single execution of a task.

Enums§

NodeState
Node state in cluster
PollenError
Main error type for Pollen operations.
Schedule
Schedule configuration for a task.
Storage
Storage configuration
TaskStatus
Status of a task instance.

Type Aliases§

Result
Result type for Pollen operations.