Skip to content

Rename Runner to Queue? #19

@mre

Description

@mre

I was thinking about a better name for Runner, since it caused some confusion.
Here's my proposal:

Main Type

Runner → Queue
RunnerHandle → QueueHandle

Method Names:

Runner::new() → Queue::new()
runner.start() → queue.start()
handle.wait_for_shutdown() → handle.wait_for_shutdown() // keep as-is
.configure_queue("emails", |queue| ...) → .configure_queue("emails", |config| ...)
.shutdown_when_queue_empty() → .shutdown_when_empty()
.configure_default_queue() → .configure_queue(DEFAULT_QUEUE, ...)

Usage Example

  use workers::{Queue, BackgroundJob, DEFAULT_QUEUE};

  // Create a queue system
  let queue = Queue::new(pool, context)
      .register_job_type::<EmailJob>()
      .register_job_type::<PaymentJob>()
      .configure_queue("emails", |config| {
          config.num_workers(4)
                .archive_completed_jobs(true)
      })
      .configure_queue("payments", |config| {
          config.num_workers(2)
                .priority_processing(true)
      });

  // Start processing
  let handle = queue.start();
  handle.wait_for_shutdown().await;

Alternatives

  • Supervisor
  • Manager

My hope is that this makes the API read naturally: "Create a queue, configure its workers, start processing jobs."

@M3t0r, wdyt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions