Skip to content

Conversation

@tyt2y3
Copy link
Collaborator

@tyt2y3 tyt2y3 commented Jan 5, 2026

Queue

Basic queue:

#[derive(Serialize, oxanus::Queue)]
struct DefaultQueue;

assert_eq!(DefaultQueue.key(), "default_queue");

With options:

#[derive(Serialize, oxanus::Queue)]
#[oxanus(key = "queue_with_throttle")]
#[oxanus(concurrency = 2)]
#[oxanus(throttle(window_ms = 3, limit = 4))]
struct QueueWithThrottle;

assert_eq!(QueueWithThrottle.key(), "queue_with_throttle");
assert_eq!(QueueWithThrottle.config().concurrency, 2);
assert_eq!(QueueWithThrottle.config().throttle.unwrap().window_ms, 3);
assert_eq!(QueueWithThrottle.config().throttle.unwrap().limit, 4);

Dynamic queue:

#[derive(Serialize, oxanus::Queue)]
#[oxanus(prefix = "dyn_queue", concurrency = 2)]
struct DynQueue {
    i: i32,
}

assert_eq!(DynQueue { i: 2 }.key(), "dyn_queue#i=2");
assert_eq!(DynQueue::to_config().concurrency, 2);

Using key on dynamic queue would result in compile error, and vice versa.

Worker

Basic worker:

#[derive(Serialize, oxanus::Worker)]
struct TestWorker {}

impl TestWorker {
    async fn process(&self, ctx: &Context<WorkerContext>) -> Result<(), WorkerError> {
        Ok(())
    }
}

With options:

#[derive(Serialize, oxanus::Worker)]
#[oxanus(context = crate::WorkerContext, error = std::io::Error)]
#[oxanus(max_retries = 3, on_conflict = Replace)]
struct TestWorkerCustom {}

assert_eq!(TestWorkerCustom {}.max_retries(), 3);
assert_eq!(TestWorkerCustom {}.on_conflict(), JobConflictStrategy::Replace);

With unique_id:

#[derive(Serialize, oxanus::Worker)]
#[oxanus(unique_id = "test_worker_{id}")]
struct TestWorkerUniqueId {
    id: i32,
}

assert_eq!(
    TestWorkerUniqueId { id: 1 }.unique_id().unwrap(),
    "test_worker_1"
);

@tyt2y3 tyt2y3 marked this pull request as ready for review January 5, 2026 22:11
@tyt2y3 tyt2y3 marked this pull request as draft January 6, 2026 10:45
@tyt2y3 tyt2y3 marked this pull request as ready for review January 6, 2026 10:45
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.

love it ❤️

@reneklacan reneklacan merged commit 9955741 into pragmaplatform:main Jan 6, 2026
1 check passed
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.

2 participants