queue

command
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ¶

Queue (Redis-based) Module

Overview

The queue module provides a distributed task queue built on top of Redis. It relies on the generic worker pool and scheduler mechanism to execute background jobs securely and concurrently.

Key Structs & Configs

  • queue.Config: Configurations for the queue workers.
    • Concurrency: Number of worker goroutines (Default: 10).
    • ShutdownTimeout: Duration to wait for in-flight jobs to complete during q.Stop() before forcing exit.
  • registry: A central package to register tasks (registry.Register(...)).

🚨 Best Practices for AI/Developers

  • Task Registration (IMPORTANT): In this specific main.go example, the task handler and init() function are written directly in the same file so you can see all the code at once. However, in a real project, you MUST structure your tasks in separate packages (e.g. tasks/email.go) using init() functions to register them, and then use a blank import (_ "github.com/.../tasks") in main.go to trigger the registration.
  • Graceful Shutdown (CRITICAL): Always intercept OS signals (SIGINT, SIGTERM) and call q.Stop() in a separate goroutine to allow the workers to drain safely within the ShutdownTimeout window.
  • Dependency Loading: Ensure Redis is connected and initialized (gored.SetDefault) before calling queue.New(rdb, config).

Documentation ¶

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL