Skip to content

Conversation

@tyt2y3
Copy link
Collaborator

@tyt2y3 tyt2y3 commented Jan 8, 2026

schedule is now part of Worker definition:

#[derive(Debug, Serialize, Deserialize, oxanus::Worker)]
#[oxanus(cron(schedule = "*/5 * * * * *", queue = QueueOne))]
struct TestWorker {}

impl TestWorker {
    async fn process(&self, _: &oxanus::Context<WorkerState>) -> Result<(), WorkerError> {
        tokio::time::sleep(std::time::Duration::from_secs(1)).await;
        Ok(())
    }
}

it can be registered just like a normal worker:

let config = oxanus::Config::new(&storage).register_worker::<TestWorker>();

cron worker with dynamic queues is still supported with the old API:

#[derive(Debug, Serialize, Deserialize, oxanus::Worker)]
#[oxanus(max_retries = 3, retry_delay = 0)]
#[oxanus(cron(schedule = "*/10 * * * * *"))]
struct TestCronWorker {}

let config = oxanus::Config::new(&storage).register_cron_worker::<TestCronWorker>(QueueDynamic(2));

@tyt2y3 tyt2y3 changed the title Cron worker Change Cron worker API and update all examples Jan 8, 2026
Copy link
Member

@reneklacan reneklacan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@tyt2y3 tyt2y3 marked this pull request as ready for review January 10, 2026 12:25
@tyt2y3 tyt2y3 merged commit d43a05a into main Jan 10, 2026
2 checks passed
@tyt2y3 tyt2y3 deleted the cron-worker branch January 10, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants